I have built a line item table for a customer using the Laserfiche samples for Total etc. I have simplified it for this question.
The calculation is correct when I add a new row. However if I delete a row the Total keeps its previous value. That is, the Total still includes the deleted row.
If I click into the table it will change.
Is there any way I can get the total to automatically update after a line deletion? It would appear that Forms does not count this as a "change".
Perhaps a refresh button?
$(document).ready(function () { $('.itemsAUD').on('blur', 'input', linetotal); function linetotal() { var sum = 0; $('.cf-table-block tbody tr').each(function () { var s = 0; s = parseNumber($(this).find('.qty input').val()) * parseNumber($(this).find('.unitprice input').val()); $(this).find('.linetotal input').val(s.toFixed(2)); sum += s; }); $(".total input").val(sum.toFixed(2)); } function parseNumber(n) { var f = parseFloat(n); return isNaN(f) ? 0 : f; } });
Table with two rows:
Table with second line removed; the Total is incorrect: