var formobj = document.getElementById('FORM_ID');
var counter = 0;
for (var j = 0; j < formobj.elements.length; j++)
{
if (formobj.elements[j].type == "checkbox")
{
if (formobj.elements[j].checked)
{
counter++;
}
}
}
alert('Total Checked = ' + counter);
This javascript is using to find number of total checkboxes in form or page and also
user can find from all checkboxes how many is checked. In this 'FORM_ID' is the id
of <form>.
No comments:
Post a Comment