I am creating a form that has select inputs and the values add up to a certain score. I can't get the values from the select to add and the sum into the total input to show the score of their test.
jscript:
function calculate_total(){
var elems = document.getElementsByClassName('Assessment');
var myLength = elems.length,
total = 0;
for (var i = 0; i < myLength; ++i) {
total += parseInt(elems[i].value * 1);
}
document.getElementById('ScoreTot').value = total;
}
html:
<cfselect name="SELECT1" id="select1" class="Assessment">
<option value="0"> OPTION 1 </option>
<option value="1"> OPTION 2 </option>
</cfselect>
<cfselect name="select2" id="select2" class="Assessment">
<option value="0"> OPTION 1 </option>
<option value="1"> OPTION 2 </option>
<option value="2"> OPTION 3 </option>
</cfselect>
<cfselect name="select3" id="select3" class="Assessment">
<option value="0"> OPTION 1 </option>
<option value="1"> OPTION 2 </option>
<option value="2"> OPTION 3 </option>
</cfselect>
Score: <cfinput type="text" name="ScoreTot" id="ScoreTot" value="">
cfselect?calculate_totalfunction++itoi++