Having an odd behavior with a form and calculating totals and were wondering if anyone can offer a little help.
We have a table that gets populated by a stored procedure. The users access the Form by clicking a link. In the URL is the variable needed so the page loads with the variable in place, the procedure happens, and the table is populated. This works great.
However, we have a Total Verified Asset Balance field (number field) that holds the total of all the Verified Balance columns. When we have nothing in the verified balance columns it is showing 0, not nothing. For this process, empty means the verification has not happened yet. 0 means that the assets could be 0 so there is a difference.
Also, when we hit our Add button for the table, it immediately puts a 3. It's as if it is seeing the rows as the values.
If we do put totals in it is not correct:
Finally, if we submit that form and then go back to it the stored procedure runs and indeed returns the correct balances, but the total then shows nothing (seems that the JS does not see them?)
We cannot use Forms calculations due to bugs when removing all rows (current filed SCR, not sure about when it will be released).
Below is the code we have. Any help would be appreciated.
function sumtotal() { var sum = 0; $('td.asset').each(function () { var s = 0; $(this).find('input').each(function () { s += parseNumber($(this).val()); }) sum += s; }); $('.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; }