Hello everyone. I am new here but have lurked quite a lot.
I have multiple forms that contain drop downs that need to be summed together. My current JS passes through a couple check box values then calculates. All of this works swimmingly. The place I have been getting stuck is I want to use this JS across all my forms regardless of the number of dropdowns. My current code is:
<script type="text/javascript">
function updatesum() {
if (document.getElementById("autofail1").checked == true) {
document.form.totalscore.value = "0";
}
else if
(document.getElementById("autofail2").checked == true) {
document.form.totalscore.value = "0";
}
else
{
document.form.totalscore.value =
(document.form.category1.options[document.form.category1.selectedIndex].text-0) +
(document.form.category2.options[document.form.category2.selectedIndex].text-0) +
(document.form.category3.options[document.form.category3.selectedIndex].text-0) +
(document.form.category4.options[document.form.category4.selectedIndex].text-0) +
(document.form.category5.options[document.form.category5.selectedIndex].text-0) +
(document.form.category6.options[document.form.category6.selectedIndex].text-0) +
(document.form.category7.options[document.form.category7.selectedIndex].text-0) +
(document.form.category8.options[document.form.category8.selectedIndex].text-0) +
(document.form.category9.options[document.form.category9.selectedIndex].text-0) +
(document.form.category10.options[document.form.category10.selectedIndex].text-0) +
(document.form.category11.options[document.form.category11.selectedIndex].text-0) +
(document.form.category12.options[document.form.category12.selectedIndex].text-0) +
(document.form.category13.options[document.form.category13.selectedIndex].text-0) +
(document.form.category14.options[document.form.category14.selectedIndex].text-0) ;
}
}
</script>
Thank you for your help.