/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function checkAll(fmobj, checkAllId) { for (var i=0;i<fmobj.elements.length;i++) { var e = fmobj.elements[i]; if ( (e.id != checkAllId) && (e.type=='checkbox') && (!e.disabled) ) { e.checked = document.getElementById(checkAllId).checked; } } } function checkCheckAll(fmobj, checkAllId ) { var TotalBoxes = 0; TotalOn = 0; for (var i=0;i<fmobj.elements.length;i++) { var e = fmobj.elements[i]; if ((e.name != checkAllId ) && (e.type=='checkbox')) { TotalBoxes++; if (e.checked) { TotalOn++; } } } if (TotalBoxes==TotalOn) { document.getElementById(checkAllId).checked=true; } else { document.getElementById(checkAllId).checked=false; } }