Hi,
I have 3 Table fields with an Estimated Cost value. css class for table 1 is estc1, css class for table 2 is estc2 and css class for table 3 is estc3. The total is suppose to be the calculated value of estc1 + estc2 + estc3. The css class for the Total Estimated Cost is total. I know i am doing something silly. What am i missing?
$(function() { $(document).ready(function () { function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } function sumtotal() { var s = 0; var s1 = 0; var s2 = 0; $('.cf-table-block tbody').each(function () { s = parseNumber($(this).find('.estc1 input').val()); s1 = parseNumber($(this).find('.estc2 input').val()); s2 = parseNumber($(this).find('.estc3 input').val()); }); $('.total input').val(s + s1 + s2); } $('.cf-table-block').change(sumtotal); }); });