当前位置:阳诡子 > 建站 > 正文

JS全选、全消、反选

时间:2020-07-30  来源:  作者:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>复选框的全选、全消、反选</title>
<SCRIPT LANGUAGE="JavaScript">
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;
}
}
</script>
</head>
<body>
<form name="checkboxform">
<input type="checkbox" name="C1" checked="checked" />C1<br>
<input type="checkbox" name="C2" checked="checked" />C2<br>
<input type="checkbox" name="C3" checked="checked" />C3<br>
<input type="checkbox" name="C4" checked="checked" />C4<br>
<input type="checkbox" name="C5" checked="checked" />C5<br>
<input type="checkbox" name="C6" checked="checked" />C6<br>
<input type="checkbox" name="C7" checked="checked" />C7<br>
<input type="checkbox" name="C8" checked="checked" />C8<br>
<input type="checkbox" name="C9" checked="checked" />C9<br>
<br />
<input type="button" value="全选" onClick="checkAll()" />
<input type="button" value="全消" onClick="uncheckAll()" />
<input type="button" value="反选" onClick="switchAll()" />
</form>
</body>
</html>
来顶一下
返回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
相关文章
CopyRight 2008-2022, 529600.Net, Inc.All Rights Reserved
粤ICP备2022094815号-1  网安备案粤公网安备 44178102001207号