Im attempting to round a few variables to 2 decimal places but am having issues
When i use the toFixed() on just the totalprice variable it works find (obviously shipping doesnt round) but when I have it like below (.toFixed on shipping var) javascript console gives me this error:
Uncaught TypeError: Object 219.863.80 has no method 'toFixed'
updatePriceshg-buy.html:398
(anonymous function)hg-buy.html:436
onchangehg
219.86 is the value of price, 63.80 is the price of shipping so it looks like it is concatenating but i cannot work out how to fix it.
Thanks in advance
Code Below
function updatePrices() {
var price = $('select_1').getValue();
var shipping = $('shippingValue').getValue();
var quantity = $('select_3').getValue();
var totalshipping = (shipping * quantity).toFixed(2);
var totalprice = ((price * quantity)+(totalshipping)).toFixed(2);
$('unitprice').setText(price);
$('shipping').setText(totalshipping);
$('totalprice').setText(totalprice);
}
Try: