I want the Grand Total calculation now.. I want the sum of all the values in the Amount field... I tried tis code but its not working...
$(".amt").each(function(){
total=total+(parseInt($(this).val()))
});
I want the Grand Total calculation now.. I want the sum of all the values in the Amount field... I tried tis code but its not working...
$(".amt").each(function(){
total=total+(parseInt($(this).val()))
});
According to the following HTML:
<table>
<tr>
<td><input class="amt" /></td>
</tr>
<tr>
<td><input class="amt" /></td>
</tr>
</table>
<div id="total"></div>
The JS would be:
$('table').focusout(function() {
var sum = 0;
$('.amt').each(function(){
if (this.value != "") {
sum += parseFloat(this.value);
}
});
$('#total').html("Grand total: " + sum);
});
<kbd>JsFiddle</kbd>