asked on March 15, 2016
•
Show version history
Hello,
I have the following code & need some help.
The Class .subtotal should have ' as separator & should have 2 decimal points
The Class .total & .sub should have ' as separator
$(document).ready(function () { $('.cf-table-block').on('blur', 'input', sumtotal); $('.tax').on('blur', 'input', sumtotal); function sumtotal() { var sum = 0; $('.cf-table-block tbody tr').filter(':visible').each(function () { var s = 0; s = parseNumber($(this).find('.price input').val()) * parseNumber($(this).find('.quantity input').val()); $(this).find('.subtotal input').val(s); sum += s; }); $('.tax input').val((sum * 0.08).toFixed(2)); $('.sub input').val((sum).toFixed(2)); $('.total input').val((parseNumber(sum) + parseNumber($('.tax input').val())).toFixed(2)); } function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } });
I have tried various codes (from here) to achieve the result, but to no luck.
Please note the fields are of type = SingleLine
Thanks a lot in advance!
S
0
0