script_iconI often want to select all of the check boxes on a web page with Java Script; mainly for twitter related services, but can never find good code that doesn’t mess up the session and not allow it to be used again on the same page without refreshing. So.. this does exactly that.

You can also change the range of the checkboxes that are selected by changing the condition bounding ‘i’.

Select All Check Boxes on Page:

javascript:function check(){var c=new Array();c=window.document.getElementsByTagName(‘input’);for(var i=0;i<c.length;i++){if(c[i].type==’checkbox’){c[i].checked=true;}}}check();

Deselct All Check Boxes on Page:

javascript:function check(){var c=new Array();c=window.document.getElementsByTagName(‘input’);for(var i=0;i<c.length;i++){if(c[i].type==’checkbox’){c[i].checked=false;}}}check();

Select First 100 Check Boxes on Page

javascript:function check(){var c=new Array();c=window.document.getElementsByTagName(‘input’);for(var i=0;i<100;i++){if(c[i].type==’checkbox’){c[i].checked=true;}}}check();

Just copy and paste it in to your address bar and press return.

Chris