I developed a form in 9.1.1 with a table containing repeatable rows containing a 'quantity', 'price' and 'subtotal' column. I also included a separate 'total' field. Fields have been set up with the respective names 'quantity', 'price', 'subtotal' and 'total'. Fields are also not read only.
I copied the Purchase Order Example into the form minus tax and shipping. The form will accept entries for 'quantity' and 'price' but will not calculate 'subtotal' and 'total'. Does anyone know why? Below is what I entered. Thank you
- $(document).ready(function () {
- $('.cf-table-block').on('blur', 'input', sumtotal);
- $('.tax').on('blur', 'input', sumtotal);
- $('.shipping').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;
- sum += parseNumber($('.tax input').val()) + parseNumber($('.shipping input').val());
- });
- $('.total input').val(sum);
- }
- function parseNumber(n) {
- var f = parseFloat(n); //Convert to float number.
- return isNaN(f) ? 0 : f; //treat invalid input as 0;
- }
- });