Return to Snippet

Revision: 47149
at June 1, 2011 18:37 by mariraj


Initial Code
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;
  }
}

Initial URL

                                

Initial Description

                                

Initial Title
Check all and uncheck all

Initial Tags

                                

Initial Language
JavaScript