复制代码代码如下:
<cript>
fonction func () {
var options = document.getElementsByName ("chkbox");
pour (var i = 0; i <options.length; i ++) {
if (! Options [i] .Disabled) {
Options [i] .checked = true;
}
}
}
</cript>
<input type = checkbox name = chkbox value = 1 désactivé>
<input type = checkbox name = chkbox value = 1>
<input type = checkbox name = chkbox value = 1>
<input type = checkbox name = chkbox value = 1>
<entrée type = Button Value = "测 试" onClick = "func ()">
用 JavaScript 吧。
复制代码代码如下:
<html>
<body>
<cript>
fonction kk () {
var handleel = document.getElementById ("kkhandler");
var els = document.getElementsByName ("kk");
pour (i = 0; i <els.length; i ++) {
els [i] .checked = handleel.checked;
}
}
</cript>
<input type = checkbox onclick = "kk ()" name = "kkhandler"> 全选 <br>
<input type = checkbox name = "kk">
<input type = checkbox name = "kk">
</docy>
</html>
2:
复制代码代码如下:
<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 = "choisi" value = "" onclick = "selectall ()" id = "checkbox5"> allElect
</ form>
<cript>
fonction selectall ()
{
if (! document.form.id.length) {
if (document.form.chose.checked) {
document.form.id.checked = true;
}
autre{
document.form.id.checked = false;
}
}
autre{
pour (var i = 0; i <document.form.id.length; i ++) {
if (document.form.chose.checked) {
document.form.id [i] .checked = true;
}
autre{
document.form.id [i] .checked = false;
}
}
}
}
</cript>
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 = 'bouton' value = '全选' onclick = 'check_all ();'>
<cript>
fonction check_all () {
arr = document.getElementsByName ('info');
for (i = 0; i <arr.length; i ++) {
arr [i] .checked = true;
}
}
</cript>