I am trying to create a form that adds numbers to two decimal points. That is, to be able to add 5.5 from 105.67 from 12.54 and get: 123.71
That's how pleased I am, but when I try to add .toFixed (2), it either just does the inputs, not the general one ...
I am very new to Javascript, so just find a way in mo
Here is my jsfiddle: https://jsfiddle.net/Vicky1984/Lpwcuyb5/d
Here is the code I'm using;
function findTotal() {
var arr = document.getElementsByName('qty');
var tot = 0;
for (var i = 0; i < arr.length; i++) {
if (parseInt(arr[i].value))
tot += parseInt(arr[i].value);
}
document.getElementById('total').value = tot;
}
early
source
share