复制代码代码如下:
<script>
función func () {
Var opciones = document.getElementsByName ("chkbox");
para (var i = 0; i <options.length; i ++) {
if (! options [i] .disable) {
opciones [i] .ecked = true;
}
}
}
</script>
<input type = checkbox name = chkbox value = 1 deshabilitado>
<input type = checkbox name = chkbox value = 1>
<input type = checkbox name = chkbox value = 1>
<input type = checkbox name = chkbox value = 1>
<Entrada type = button value = "测 试" onClick = "func ()">
用 JavaScript 吧。
复制代码代码如下:
<html>
<Body>
<script>
función kk () {
var handleel = document.getElementById ("kkhandler");
var els = document.getElementsByName ("kk");
para (i = 0; i <els.length; i ++) {
els [i] .ecked = handleel.ecked;
}
}
</script>
<input type = checkbox onClick = "kk ()" name = "kkhandler"> 全选 <br>
<input type = checkbox name = "kk">
<input type = checkbox name = "kk">
</body>
</html>
2:
复制代码代码如下:
<form de nombre = "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 = "ochee" value = "" onClick = "selectAll ()" id = "CheckBox5"> AllSelect
</form>
<script>
función selectAll ()
{
if (! document.form.id.length) {
if (document.form.chose.ecked) {
document.form.id.ecked = true;
}
demás{
document.form.id.ecked = false;
}
}
demás{
for (var i = 0; i <document.form.id.length; i ++) {
if (document.form.chose.ecked) {
document.form.id [i] .ecked = true;
}
demás{
document.form.id [i] .ecked = false;
}
}
}
}
</script>
3:
复制代码代码如下:
<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 = '全选' onClick = 'check_all ();'>
<script>
función check_all () {
arr = document.getElementsByName ('info');
para (i = 0; i <arr.length; i ++) {
arr [i] .ecked = true;
}
}
</script>