Jump to content

Submission form calculation


Recommended Posts

I need to calculate the total value of the fields GAD1 - GAD7 which are all drop downs with text that have a corresponding numeric value.  
that total needs to be inserted into the hidden field GAD_Score when the user submits the page.
All of the fields mentioned above are number datatypes in the corresponding table.
when I test it out using either the preview or on my website I get nothing in the GAD_Score field in my table, what am I missing?   
Here is the code I put in the footer of my data page.
 
<SCRIPT LANGUAGE="JavaScript">
 
 function calculate()
 {
   var v_GAD1 = parseFloat(document.getElementById("InsertRecordGAD_Q1").value);
   var v_GAD2 = parseFloat(document.getElementById("InsertRecordGAD_Q2").value);
   var v_GAD3 = parseFloat(document.getElementById("InsertRecordGAD_Q3").value);
   var v_GAD4 = parseFloat(document.getElementById("InsertRecordGAD_Q4").value);
   var v_GAD5 = parseFloat(document.getElementById("InsertRecordGAD_Q5").value);
   var v_GAD6 = parseFloat(document.getElementById("InsertRecordGAD_Q6").value);
   var v_GAD7 = parseFloat(document.getElementById("InsertRecordGAD_Q7").value);
 
var v_GADSCORE= v_GAD1 + v_GAD2 + v_GAD3 + v_GAD4 + v_GAD5 + v_GAD6 + v_GAD7;
 
document.getElementById("InsertRecordGAD_Score").value = Math.round(v_GADSCORE);
 
 }
 document.getElementById("caspioform").onsubmit=calculate;
 
</SCRIPT>
 
Any help would be greatly appreciated :)
 
 
 
Link to comment
Share on other sites

  • 2 years later...

Hi @Trevor,

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 as your total value for all your fields.

Check these videos for more information:

 

 

 

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.

Guest
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.

Loading...
 Share

×
×
  • Create New...