<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8"> <title></title> <Script>window.onload= function(){ varOBTN1=document.getElementById ('BTN1'); varobtn2=document.getElementById ('btn2'); varObtn3=document.getElementById ('Btn3'); varOdiv=document.getElementById ('Div1'); varOcheck=Odiv.getelementsbytagname ('input'); Obtn1.onclick= function(){ //Select All for(varI=0; I<Ocheck.length;i++) {ocheck[i].checked= true; } }; Obtn2.onclick= function(){ //not selected for(varI=0; I<Ocheck.length;i++) {ocheck[i].checked= false; } }; Obtn3.onclick= function(){ //Inverse Selection for(varI=0; I<Ocheck.length;i++) {ocheck[i].checked= !ocheck[i].checked; } }; } </Script>Code as follows,
</Head> <Body> <inputtype= "button"ID= "BTN1"value= "Select All" /> <inputtype= "button"ID= "BTN2"value= "Not selected" /> <inputtype= "button"ID= "Btn3"value= "Reverse Selection" /> <DivID= "Div1"> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> <inputtype= "checkbox" /><BR/> </Div> </Body></HTML>
Pure JS Write check box Select all, select all, reverse