Checkall or Invert Checkboxes

[Total: 0    Average: 0/5]

This will select all – or invert the selected checkboxes.

Body Code:


function set(n) 
               temp = document.main.elements.length  ;
               for (i=0; i < temp; i++)
	{   document.main.elements[i].checked=n;

function Invers(){

temp = document.main.elements.length ;
for (i=0; i < temp; i++){

          if(document.main.elements[i].checked == 1){document.main.elements[i].checked = 0;}
                else {document.main.elements[i].checked = 1}


<FORM  method=post name=main>
<INPUT name=chbox type=checkbox value=1>
<INPUT name=chbox type=checkbox value=2>
<INPUT name=chbox type=checkbox value=3>
<INPUT name=chbox type=checkbox value=4>
<INPUT name=chbox type=checkbox value=5>
<INPUT name=button onclick=set(1) type=button value="Select All"> 
<INPUT name=button onclick=Invers() type=button value=" Invert "> 
<INPUT name=button onclick=set(0) type=button value=" Reset "> 

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *