Mylene Posted May 30, 2016 Report Share Posted May 30, 2016 Hi, I need help with calculating total sum based on values, entered in fields. I have 3 fields on the submission form, where users enter 3 values. I would like to calculate total in the forth field. Also, I want to show the value to the user. E.g when user enters value "5" in the first field, he will see "5" in the field Total then user enters "10" in the second field, he will see "15" in the field Total and finally user enters "7" in the third field, he will see "22" in the field Total And I wand to store value 22 in the table. Thanks! Quote Link to comment Share on other sites More sharing options...
Mathilda Posted May 30, 2016 Report Share Posted May 30, 2016 Hi Mylene, I have taken a script from this post and changed a little bit. Paste following script in the footer of the datapage: <SCRIPT LANGUAGE="JavaScript"> function calculate() { var v_field1 = parseFloat(document.getElementById("InsertRecordfield1").value); if (isNaN(v_field1)) v_field1 = 0; var v_field2 = parseFloat(document.getElementById("InsertRecordfield2").value); if (isNaN(v_field2)) v_field2 = 0; var v_field3 = parseFloat(document.getElementById("InsertRecordfield3").value); if (isNaN(v_field3)) v_field3 = 0; var v_total = (v_field1 + v_field2+v_field3); document.getElementById("InsertRecordfield4").value = (v_total); } /* On submitting the webform, the function calculate is executed */ document.getElementById("caspioform").onchange=calculate; </SCRIPT> Replace field1...field4 with your field names. Please note, that field names are case sensitive, they must be the same as you have named them in the table. Hope it helps. Quote Link to comment Share on other sites More sharing options...
Kurumi Posted October 22, 2018 Report Share Posted October 22, 2018 Hi @Mylene, As of July 12, 2018, Caspio introduced new features which you can find here: https://howto.caspio.com/release-notes/caspio-bridge-13-0/ This release includes a new feature, Calculated Values in Submission Forms. This allows you to generate calculations which you can use for your total sum. Check these videos for more information: I hope this helps! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.