We are using the following code to add rows in a table. We have the ccs class of sum entered on the table. However, this adds any value that has a number in it.
$(document).ready(function () {
$('.sum').on('blur', 'input', sumtotal);
function sumtotal() {
var s = 0;
$('.sum input').each(function () {
s += parseNumber($(this).val());
});
$('.total input').val(s);
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
}
});
We also tried setting the column css class to sum for the appropriate column and this will add correctly for the first row but subsequent rows will not be added to the total unless we go back and change the value in the first row. Is there something we need to change in the code?
Thanks,