Reputation: 267
var cbx = document.getElementById('ModelFilter').getElementsByTagName('input');
var ArrCB_l=cbx.length;
while(ArrCB_l--){
var CB=ArrCB[ArrCB_l];
CB.checked()==True;
return 1
}
return 0
Can anyone tell me what is wrong with this? I know the first line is the correct input as I am using it elsewhere for the same checkboxes, however this won't work? I am trying to make sure there is at least one checkbox checked. This function is called with an onsubmit event.
Upvotes: 0
Views: 181
Reputation: 2423
while(ArrCB_1) {
if(cbx[--ArrCB_1].checked) {
return true;
}
}
return false;
Upvotes: 1
Reputation: 1874
document.getElementById('ModelFilter').getElementsByTagName('input');
this code returns all inputs(text,button,radio etc)
use
document.getElementById('ModelFilter').getElementsByTagName("input")[ArrCB_l].type == "checkbox"
Upvotes: 0
Reputation: 123377
while(ArrCB_l--){
if (cbx[ArrCB_l].checked) {
return true;
}
}
return false;
your collection is cbx
and not ArrCB
, and checked is not a method but it's an attribute/property of the element
Upvotes: 0