asked on April 4, 2017
We have a form that totals a value in a table. The calculation works fine as long as the user does not need to remove a row. If they do, the total is not updated unless they click into the field with the res-sum class. How can I change the code to update automatically?
$(document).ready(function () { $(document).on('blur change', '.res-sum input', sumtotal); function sumtotal() { var s = 0; $('.res-sum input').each(function () { s += parseNumber($(this).val()); }); $('.res-total input').val((s).toFixed(2)); } function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } })
0
0