Hi,
I created a form as a software where users could put some information. I'd like to create some fields "test1, test2, test3" as numbers, and then create the field "testSum" where I have the sum of the test fields.
Could you help me, please?
Thank you in advance.
Vito
I created a form as a software where users could put some information. I'd like to create some fields "test1, test2, test3" as numbers, and then create the field "testSum" where I have the sum of the test fields.
Could you help me, please?
Thank you in advance.
Vito
Hi BASSI,
You can do this using JavaScript in a Load JavaScript action in the form On Load event. Here's an example
Bob
You can do this using JavaScript in a Load JavaScript action in the form On Load event. Here's an example
jQuery(document).ready(function(jQ) {
var box_1, box_2, box_3, total;
jQ('#box_1').keyup(calculateTotal);
jQ('#box_2').keyup(calculateTotal);
jQ('#box_3').keyup(calculateTotal);
function calculateTotal() {
total = 0;
box_1 = jQ('#box_1').val();
if ( isNaN(box_1) || !box_1 ) {
box_1 = 0;
}
total += parseFloat(box_1);
box_2 = jQ('#box_2').val();
if ( isNaN(box_2) || !box_2 ) {
box_2 = 0;
}
total += parseFloat(box_2);
box_3 = jQ('#box_3').val();
if ( isNaN(box_3) || !box_3 ) {
box_3 = 0;
}
total += parseFloat(box_3);
jQ('#total').val(total);
}
});
Bob
I'm sorry I don't know JS script. I tried to put it on "setup" load Javascript, also I change the names of the var as the fields name, and then I call the function name for the three fields, but it doesn't work. Probably I lost a passage... 🙂
Hi Grey, could you explain how I can obtain the result? Thank you very much.
Vito
Vito
Hi Vito,
The JavaScript uses the element IDs, not the names (it helps if they are the same).
Check this, if that doesn't work you probably need help from someone with more JavaScript experience.
Bob
The JavaScript uses the element IDs, not the names (it helps if they are the same).
Check this, if that doesn't work you probably need help from someone with more JavaScript experience.
Bob
This topic is locked and no more replies can be posted.