I have a form in which I need to subtract two fields, then enter the difference into a third field. I have tried the following code which was suggested from an earlier post, which suggested using the example from the help file and make a change to a line of the code. However, the results that I am getting are the two fields are simply added together 3 times and given a negative sign. I have included a screenshot of the form below. I am wanting to subtract the "Reading" field from the "Processed Reading" field. The "Reading" field is entered by the user and the "Processed Reading" is populated from a table lookup from our billing application based on the meter number entered. As per the instructions from the help file, I have added "sum" to the CSS class under the advanced tab for each of the two fields and "total" to the CSS class of the variance field. As a side note.... Does anyone know how to remove the comma from the numbers to that it would display as 59100 instead of 59,100?
$(document).ready(function () {
$('.sum').on('blur', 'input', sumtotal);
function sumtotal() {
var s = 0;
$('.sum input').each(function () {
s -= parseNumber($(this).val());
});
$('.total input').val(s);
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; }
});