tags:

views:

62

answers:

2

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
+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