复制代码代码如下:
<script>
fungsi func () {
var options = document.geteLementsByName ("chkbox");
untuk (var i = 0; i <options.length; i ++) {
if (! Options [i] .disabled) {
opsi [i] .Checked = true;
}
}
}
</script>
<Jenis input = centang nama = nilai chkbox = 1 dinonaktifkan>
<Jenis input = nama kotak centang = nilai chkbox = 1>
<Jenis input = nama kotak centang = nilai chkbox = 1>
<Jenis input = nama kotak centang = nilai chkbox = 1>
<input type = tombol value = "测 试" onClick = "func ()">
用 JavaScript 吧。
复制代码代码如下:
<Html>
<body>
<script>
fungsi kk () {
var handleel = document.geteLementById ("kkhandler");
var els = document.geteLementsbyname ("kk");
untuk (i = 0; i <els.length; i ++) {
els [i] .Checked = handleel.Checked;
}
}
</script>
<input type = centang kotak onclick = "kk ()" name = "kkhandler"> 全选 <br>
<Input type = centang nama = "kk">
<Input type = centang nama = "kk">
</body>
</html>
2:
复制代码代码如下:
<Form name = "Form" id = "Form1">
<input type = "centang kotak" name = "id" value = "" id = "checkbox1"> 1
<input type = "centang kotak" name = "id" value = "" id = "checkbox2"> 2
<input type = "centang kotak" nama = "pilih" 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;
}
kalau tidak{
document.form.id.checked = false;
}
}
kalau tidak{
untuk (var i = 0; i <document.form.id.length; i ++) {
if (document.form.chose.checked) {
Document.Form.id [i] .Checked = true;
}
kalau tidak{
Document.Form.id [i] .Checked = false;
}
}
}
}
</script>
3:
复制代码代码如下:
<input type = 'centang kotak' nama = 'info' value = 'a'>
<input type = 'centang kotak' nama = 'info' value = 'b'>
<input type = 'centang kotak' nama = 'info' value = 'c'>
<input type = 'centang kotak' nama = 'info' value = 'd'>
<input type = 'centang kotak' nama = 'info' value = 'e'> <br>
<input type = 'tombol' value = '全选' onclick = 'check_all ();'>
<script>
function check_all () {
arr = document.geteLementsByName ('info');
untuk (i = 0; i <arr.length; i ++) {
ARR [i] .Checked = true;
}
}
</script>