$("#diskamountUnit"). val('$' + $("#disk"). slider("value") * 1.60);
Use the toFixed() method to format a number to 2 decimal places, e.g. num. toFixed(2) . The toFixed method takes a parameter, representing how many digits should appear after the decimal and returns the result.
To add two decimal numbers in JavaScript use the toFixed() function to convert it to a string with some decimal places shaved off, and then convert it back to a number.
I am trying to add two decimal values but the returned sum is pure integer. What is wrong? I can't find it. any help will be welcome.
jQuery(".delivery-method #ship_select").change(function(){
var cost = jQuery(this).val();
jQuery("#delivery_cost").val(cost); //returns 20.00
var tot = parseInt(cost) + parseInt(total); //total returns 71.96
});
With the code i am getting only 91
and not 91.96
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With