Chinaunix

标题: 如何,实现点击“全部"复选框,选上下面全部的复选框 [打印本页]

作者: baorongabc    时间: 2008-07-02 14:28
标题: 如何,实现点击“全部"复选框,选上下面全部的复选框
如何,实现点击“全部"复选框,选上下面全部的复选框
求代码.

1.JPG (6.41 KB, 下载次数: 55)

1.JPG

作者: bjwyh    时间: 2008-08-31 14:47
标题: 转一个你看吧
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页特效代码|JsCode.CN|---复选框全选、全不选和反选的效果实现</title>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkAll() {
for (var j = 1; j <= 9; j++) {
box = eval("document.checkboxform.C" + j);
if (box.checked == false) box.checked = true;
   }
}

function uncheckAll() {
for (var j = 1; j <= 9; j++) {
box = eval("document.checkboxform.C" + j);
if (box.checked == true) box.checked = false;
   }
}

function switchAll() {
for (var j = 1; j <= 9; j++) {
box = eval("document.checkboxform.C" + j);
box.checked = !box.checked;
   }
}
//  End -->
</script>
</head>

<body>

<form name=checkboxform>
<input type=checkbox name=C1 checked>C1<br>
<input type=checkbox name=C2 checked>C2<br>
<input type=checkbox name=C3 checked>C3<br>
<input type=checkbox name=C4 checked>C4<br>
<input type=checkbox name=C5 checked>C5<br>
<input type=checkbox name=C6 checked>C6<br>
<input type=checkbox name=C7 checked>C7<br>
<input type=checkbox name=C8 checked>C8<br>
<input type=checkbox name=C9 checked>C9<br>
<br>
<input type=button value="全部选中" onClick="checkAll()"><br>
<input type=button value="全部不选" onClick="uncheckAll()"><br>
<input type=button value="选择转换" onClick="switchAll()"><br>
</form>

</body>

</html>
作者: realmon    时间: 2008-08-31 18:43

作者: RobinHoo    时间: 2008-09-01 17:16
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Check or Uncheck All</title>
<SCRIPT LANGUAGE="JavaScript">
function setAllCheckValue(groupName)
{
&nbsp;&nbsp;&nbsp;&nbsp;var items=document.getElementsByName(groupName);
&nbsp;&nbsp;&nbsp;&nbsp;for (var i=0;i<items.length;i++)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;items[i].checked=!items[i].checked;
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</script>
</head>

<body>

<form name=checkboxform>
<br>
<input type="checkbox" name="BasicInfo" id="setAllItems" onclick="setAllCheckValue('BasicInfo');this.checked=!this.checked;msg.innerHTML=this.checked?'全部不选中':'全部选中'" checked><span id="msg">全部不选中</span><br>
<input type="checkbox" name="BasicInfo" id="C1" checked>C1<br>
<input type="checkbox" name="BasicInfo" id="C2" checked>C2<br>
<input type="checkbox" name="BasicInfo" id="C3" checked>C3<br>
<input type="checkbox" name="BasicInfo" id="C4" checked>C4<br>
<input type="checkbox" name="BasicInfo" id="C5" checked>C5<br>
<input type="checkbox" name="BasicInfo" id="C6" checked>C6<br>
<input type="checkbox" name="BasicInfo" id="C7" checked>C7<br>
<input type="checkbox" name="BasicInfo" id="C8" checked>C8<br>
<input type="checkbox" name="BasicInfo" id="C9" checked>C9<br>

</form>

</body>

</html>


[ 本帖最后由 RobinHoo 于 2008-9-1 17:17 编辑 ]
作者: shigw001    时间: 2008-09-03 17:40
受教了 很好




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2