Wednesday, December 7, 2011

Javascript Tip: Check all checkboxes

A simple javascript function to check all checkboxes

function CheckAll(ctrl, checkVal)
{
      var i=0;

      var j=0;
      var k=0;
      var outerTR;
      var outerTD;

      var eleTbody=document.getElementById('uctrlConfigs_'+ctrl).children[0];
      outerTR=eleTBody.children;

      for (i=0;i< eleTbody.children.length;i++)
     {
           alert("ll");
           eleTR=eleTbody.children[i];
          
           for (j=0;eleTR.children.length;j++)
          {
                var innertab=eleTR.children[j].children[0].children[0];
                for(k=0;k< innertab.children.length;k++)
               {
                     alert(innertab.children[0].children[0].children[1].type);
                     innertab.children[k].children[0].children[1].checked=checkVal;
               }
          }
    }
}


Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments : on " Javascript Tip: Check all checkboxes "