This is the form. I am wanting to subtract the Balance value from the Grand Total to give me a Balance Remaining.
$(document).ready(function () { $('.cf-table-block').on('blur', 'input', sumtotal); $('.subtotal').on('blur', 'input', sumtotal) $('.quantity').on('blur', 'input', sumtotal); function sumtotal() { var sum = 0; $('.cf-table-block tbody tr').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; }); $('.total input').val(sum.toFixed(2)); } $('balance input, total input').blur(function () { $('#remaining input').val($('#balance input').val() - $('total input').val()); }); function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } });
balance is the class given to the field Balance
total is the class given to the field Grand Total which it's value is the result of the table calculations.
remaining is the class given to the field Balance Remaining
The Balance value is loaded from a database via Lookup.