All and inverse functions of checkbox, all options of checkbox
Use jQuery to implement the full and inverse selection functions of the checkbox. When the checkbox is disabled, it does not participate in the full selection function.
<! DOCTYPE html>
Implement full checkbox deselection in asp page
<Script language = javascript>
Function mm ()
{
Var a = document. getElementsByTagName ("input ");
For (var I = 0; I <a. length; I ++)
If (a [I]. type = "checkbox") a [I]. checked = true;
}
</Script>
<A href = "#" onclick = "mm (); return false;"> select all </a>
Write it by yourself.
Select All and invert the checkbox
<Html>
<Script language = javascript>
Function selectAll (){
Var a = document. getElementsByTagName ("input ");
If (a [0]. checked ){
For (var I = 0; I <a. length; I ++ ){
If (a [I]. type = "checkbox") a [I]. checked = false;
}
}
Else {
For (var I = 0; I <a. length; I ++ ){
If (a [I]. type = "checkbox") a [I]. checked = true;
}
}
}
</Script>
<Input type = "checkbox" value = 1/>
<Input type = "checkbox" value = 2/>
<Input type = "checkbox" value = 3/>
<Input type = "checkbox" value = 4/>
<Input type = "checkbox" value = 5/>
<Input type = "button" name = "select" onclick = "selectAll ()" value = "select all/not select all"/>
</Html>