how to get checked check box count in a div using javascript
+7
A:
var count = 0;
var inputs = myDiv.getElementsByTagName('input');
for (var i = 0, j = inputs.length; i<j; i++) {
var input = inputs[i];
if (input.type && input.type === 'checkbox' && input.checked) {
count++;
}
}
return count;
David Dorward
2010-02-08 09:52:03
+2
A:
If you have JQuery on your site you can do it this way (assuming yor div has id='myDiv'):
$("#myDiv input:checkbox:checked").length
Alexander Vakrilov
2010-02-08 10:05:23