Jump to content

Calculate Sum Of 3 Fields On Submission Form

Recommended Posts



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.




Link to comment
Share on other sites

Hi Mylene,



I have taken a script from this post and changed a little bit. Paste following script in the footer of the datapage:


 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 */


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.


Link to comment
Share on other sites

  • 2 years later...

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!

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...