Javascript: Check if any checkbox is checked
If you want to check if any checkbox is selected, but checkboxes have all the same name and are so part of an array, here is an example of how to do:
1 2 3 4 5 6 7 8 9 |
anychecked = false; for(var i=0; i< document.forms.form1["mycheckboxes"].length;i++) { if(document.forms.form1["mycheckboxes"][i].checked == true) { anychecked = true; break; } } if(anychecked) alert('At least one checkbox is checked'); |
Link to this post!