I set up a Repeater area with fields, add and remove buttons for entering checks for close-out procedures, and wrote a quick php custom code to parse that before sending it to the email template. There is one thing lacking, however - while I can pass each check and amount to it's own line, I'd like to also dynamically populate a field with the totals as each check is added, or removed. The name field of the form is:
checklista[{var:area_repeater54.key}][checkamount]
and the field ID is set to:
amounta
When I enter in 3 checks, this is the array I get. Arrays always tend to scramble my brains, so I'm not sure what to do after this to sum up the checkamount fields and pass that on to the field with the name and title of:
totalSuma
I have Jquery doing this for static fields that works perfectly. It uses this basic setup:
checklista[{var:area_repeater54.key}][checkamount]
and the field ID is set to:
amounta
When I enter in 3 checks, this is the array I get. Arrays always tend to scramble my brains, so I'm not sure what to do after this to sum up the checkamount fields and pass that on to the field with the name and title of:
totalSuma
I have Jquery doing this for static fields that works perfectly. It uses this basic setup:
$("#cash_deposit,#checks_deposit").on("change", function(){But...when fields are added and removed dynamically, that's where I get a little lost, like below with 3 test checks entered.
var w = parseFloat($("#cash_deposit").val());
var x = parseFloat($("#checks_deposit").val());
if ($.isNumeric(w)){} else { w = 0; }
if ($.isNumeric(x)){} else { x = 0; }
var z = w+x;
$("#deposit_total").val(z.toFixed(2));
if (z < 0) {
$("#deposit_total").css("color","red");
} else {
$("#deposit_total").css("color","black");
}
});
[checklista] => Array ( [0] => Array ( [checkname] => Bob [checkamount] => 2.33 ) [1] => Array ( [checkname] => Fred [checkamount] => 5.33 ) [2] => Array ( [checkname] => John [checkamount] => 7.33 ) )