eswbitto Hey there, I have used this JS also but it doesn't appear to work for me, have put it in a test form at https://potterandmoore.forms-db.com/view.php?id=24865 with the following script. Any help you can offer would be great, thanks.
(document).ready(function () {
var r1, r2;
if ($('#form_24865').length) { // Replace XXX with your form ID
$(document).change(function () {
r1 = $('#element_1').val();
r2 = $('#element_2').val();
// r3 = $('#element_6').val(); // Here we are setting each of these elements to an assigned variable which will hold its value to calculate later.
// r4 = $('#element_7').val();
// r5 = $('#element_8').val();
// r6 = $('#element_9').val();
// r7 = $('#element_10').val();
// r8 = $('#element_11').val();
//This is where we assign a variable (an element) and also we calculate what that variable should be from above.
tr = parseInput(r1) + parseInput(r2); //+ parseInput(r3) + parseInput(r4) + parseInput(r5) + parseInput(r6) + parseInput(r7) + parseInput(r8);
$('#element_3').val(parseInput(tr).toFixed(2));
});
}
});
// Default values to 2 decimal points
function parseInput(val) {
val = parseFloat(val, 10);
if(isNaN(val)) {
return 0;
} else {
return val;
}
}