2
I cannot hit the code below: the total variable does not sum in countCheckedCheckboxes. And when you click the button mark all but uncheck some and click on the button again what was marked descends and what was down is marked.
SCRIPT
var total=0;
function checkAll(theForm, cName) {
for (i=0,n=theForm.elements.length;i<n;i++){
if (theForm.elements[i].className.indexOf(cName) !=-1)
theForm.elements[i].checked = !(theForm.elements[i].checked);
}
total = $('input[type=checkbox]:checked').length;
}
$(document).ready(function(){
var $checkboxes = $('#checkbox_form td input[type="checkbox"]');
$checkboxes.change(function(){
var countCheckedCheckboxes = $checkboxes.filter(':checked').length;
countCheckedCheckboxes=(countCheckedCheckboxes+total);
$('#count-checked-checkboxes').text(countCheckedCheckboxes);
});
});
Thanks for the answer but there are several groups and each with a class. There are three hundred classes
– user60252
in this example the developer also used class. You can put them inside a div and for each div go through the DOM p/ see if there is checkbox p/ mark. But I see that your need will really take work to separate the checkbox groups.
– Raul Marques