Trevor Posted June 27, 2016 Report Share Posted June 27, 2016 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 Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 28, 2016 Report Share Posted June 28, 2016 one thing you can try is to get element by ID get them by name so change: document.getElementById("").value to document.getElementsByName("")[0].value If that does not help give me the URL to the page Quote Link to comment Share on other sites More sharing options...
Meekeee Posted September 17, 2018 Report Share Posted September 17, 2018 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: 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.