I have a function that sums a bunch of total fields on a page. It could be one field or many. The number could be different every time. It is working correctly but not summing the two decimal places.
So for this list of numbers:
312.69
39.00
It outputs 351 instead of 351.69
Any ideas why this is based on the following code?
settotal() {
this.totalTarget.value = Number(this.qtyTarget.value * this.costTarget.value).toFixed(2)
var arr = document.getElementsByName('total');
var tot=0;
var totf=0;
for(var i=0;i<arr.length;i++){
if(parseInt(arr[i].value))
tot += parseInt(arr[i].value);
totf = (Math.round(tot * 100) / 100).toFixed(2);
}
document.getElementById('invoice_net_amount').value = totf;
}