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