Is it possible to check if all select values inside a div, inside a form equals 1?
I don’t want to write hundreds of if statements.
Reason for this is that I am trying to validate the form, and want to check so that the user has selected something. Standard value in EVERY select list is 1 (not selected anything).
<form name="myform" onchange="return jsfunction();" etc...>
<div id="formdiv">
many many selects, all having a selected option value of 1
</div>
</form>
Not writing the code
Get all select elments using
which returns an array.
Loop through the array and get the selected value and check those.
To get the selected value you can use
document.getElementById ( elementinArrayIndex.id ).value;
where elementinArrayIndex is the select element in the current loop iteration.
If all the select elements that you want to check are inside the div element with id “formdiv” then you can use