This works but only if ALL SELECTS == 1, as soon as I change one SELECT to something else, this returns true... why?
BACKGROUND: To validate a form. I am getting all SELECT values inside a div (which contains more divs) and compare them to the number '1', and if they == 1, then an error div shows up for the user.
some code for getting all select values:
var subcats = document.getElementById("annonsera_subcats").getElementsByTagName("select");
subcatsValid(subcats)) etc etc...
Then I am using this loop in the function subcatsValid():
function subcatsValid(fld){
for (i=0; i<fld.length; i++){
if (fld[i].value==1){
document.getElementById("annonsera_subcatsempty_error").style.display='block';
document.getElementById("annonsera_subcats").focus();
return false;
}
document.getElementById("annonsera_subcatsempty_error").style.display='none';
return true;
}
}
I think the problem is in the loop... Please help! Thanks