Copy codeThe Code is as follows:
<Script>
Function func (){
Var options = document. getElementsByName ("chkBox ");
For (var I = 0; I <options. length; I ++ ){
If (! Options [I]. disabled ){
Options [I]. checked = true;
}
}
}
</Script>
<Input type = checkbox name = chkBox value = 1 disabled>
<Input type = checkbox name = chkBox value = 1>
<Input type = checkbox name = chkBox value = 1>
<Input type = checkbox name = chkBox value = 1>
<Input type = button value = "test" onclick = "func ()">
Use javascript.
Copy codeThe Code is as follows:
<Html>
<Body>
<Script>
Function kk (){
Var handleEl = document. getElementById ("kkHandler ");
Var els = document. getElementsByName ("kk ");
For (I = 0; I <els. length; I ++ ){
Els [I]. checked = handleEl. checked;
}
}
</Script>
<Input type = checkbox onclick = "kk ()" name = "kkHandler"> select all <br>
<Input type = checkbox name = "kk">
<Input type = checkbox name = "kk">
</Body>
</Html>
2:
Copy codeThe Code is as follows:
<Form name = "form" ID = "Form1">
<Input type = "checkbox" name = "id" value = "" ID = "Checkbox1"> 1
<Input type = "checkbox" name = "id" value = "" ID = "Checkbox2"> 2
<Input type = "checkbox" name = "chose" value = "" onclick = "selectAll ()" ID = "Checkbox5"> allselect
</Form>
<Script>
Function selectAll ()
{
If (! Document. form. id. length ){
If (document. form. chose. checked ){
Document. form. id. checked = true;
}
Else {
Document. form. id. checked = false;
}
}
Else {
For (var I = 0; I <document. form. id. length; I ++ ){
If (document. form. chose. checked ){
Document. form. id [I]. checked = true;
}
Else {
Document. form. id [I]. checked = false;
}
}
}
}
</Script>
3:
Copy codeThe Code is as follows:
<Input type = 'checkbox' name = 'info' value = 'A'>
<Input type = 'checkbox' name = 'info' value = 'B'>
<Input type = 'checkbox' name = 'info' value = 'C'>
<Input type = 'checkbox' name = 'info' value = 'D'>
<Input type = 'checkbox' name = 'info' value = 'E'> <br>
<Input type = 'button 'value = 'select all 'onclick = 'check _ all ();'>
<Script>
Function check_all (){
Arr = document. getElementsByName ('info ');
For (I = 0; I <arr. length; I ++ ){
Arr [I]. checked = true;
}
}
</Script>