You should avoid having two checkboxes with the same name if you plan to reference them like document.FC.c1
. If you have multiple checkboxes named c1
how will the browser know which you are referring to?
Here’s a non-jQuery solution to check if any checkboxes on the page are checked.
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
var checkedOne = Array.prototype.slice.call(checkboxes).some(x => x.checked);
You need the Array.prototype.slice.call
part to convert the NodeList
returned by document.querySelectorAll
into an array that you can call some
on.