关于复选框全选的问题???? 有现成的html吗?调试起来方便一些。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 问问题,如果能让回答的人方便的搭建调试环境,那么多省大家的时间?<html><body><input type="checkbox" name="C1" value="ON"><input type="checkbox" name="C2" value="ON"><input type="checkbox" name="C3" value="ON"><input type="checkbox" name="C4" value="ON"><input type="checkbox" name="C5" value="ON"></body></html> 利用事件触发选择所有的checkbox????<html> <head> <title>采集模板生成模块</title> <script type="text/javascript"> function checkAll(){ var checkArray = document.all("box"); for(i=0;i<checkArray[i];i++){ checkArray[i].checked=true; } } </script> </head> <body> <center> <form name="ctcForm" action="" method="post"> <table id="Table" border=2> <caption> 请选择部门所管辖的指标: </caption> <tr> <th> </th> <th align="center">指标编号</th> <th align="center">指标名称</th> </tr> <tr> <td> <input type="checkbox" name="box"> </td> <td> <input type="checkbox" name="box"> </td> <td> <input type="checkbox" name="box"> </td> </tr> </table> <br> <table> <tr> <select id="ctcSelect"> <option value="atvdc"> 年度目标值数据采集模板 </option> <option value="mavdc"> 每月完成值数据采集模板 </option> </select> </tr> </table> <br> <table> <tr> <td> <input type="button" name="buildModule" value="生成" onClick="createModule();" /> </td> <td> <input type="button" name="allCheck" value="全选" onClick="checkAll();" /> </td> <td> <input type="reset" name="reset" value="重置" /> </td> </tr> </table> </form> </center> </body></html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>全选的例子</title>[code=JScript]<script language="javascript">/*作者:Conis时间:15:33 2007/12/12功能:根据一个CheckBox的选择状态,将指定容器内的所有CheckBox都置为与些CheckBox相同的状态。一般用于点中一个CheckBox,全选/全取消一组CheckBox限制:所有的目标CheckBox必需在同一个容器中参数: oContainer:包含CheckBox的容器 oCheckAll:全选的CheckBox,目标容器中所有CheckBox都会与这个CheckBox的Checked状态一样*/function SelectAllCheckBox(oContainer, oCheckAll){ var oList = oContainer.getElementsByTagName("INPUT"); if (oList && oList.length) { for(var i = 0; i < oList.length; i ++) { if (oList[i].type != "checkbox" || oList[i] == oCheckAll) continue; oList[i].checked = oCheckAll.checked; } }}</script></head><body><table width="15%" border="0" cellspacing="0" cellpadding="0" id="tableOne"> <tr> <td><input type="checkbox" name="checkAll" id="chkAllOne" onclick="SelectAllCheckBox(document.getElementById('tableOne'), this)"/></td> </tr> <tr> <td><input type="checkbox" name="checkbox2" id="checkbox2" /> <input type="text" name="textfield" id="textfield" /></td> </tr> <tr> <td><input type="checkbox" name="checkbox3" id="checkbox3" /></td> </tr> <tr> <td><input type="checkbox" name="checkbox4" id="checkbox4" /></td> </tr> <tr> <td><input type="checkbox" name="checkbox5" id="checkbox5" /></td> </tr></table></body></html>[/code] <script language="javascript" type="text/javascript">function checkAll(){ var checkArray = document.getElementsByName("box"); for(i =0; i < checkArray.length;i++) checkArray[i].checked = true;}</script> 给你些例子http://blog.csdn.net/lifeng_beijing/archive/2007/12/14/1936512.aspx 真是无语:<script language="javascript" type="text/javascript">var bln = false;function checkAll(chkname){ var checkArray = document.getElementsByName(chkname); for(i =0; i < checkArray.length;i++) if (!bln) checkArray[i].checked = true; else checkArray[i].checked = false; bln = !bln;}</script> <input type=button value=全选 onclick=checkAll('checkbox1');> 代码优化?如何解决控件取值硬编码控件ID带来维护问题。 如何获取拖拽到浏览器窗口的文件名 复选框通过一个结果(隐藏或显示) asp.net引用了js文件,文件更新后,客户端不更新怎么办 修改一下拖动层 select实现innerHtml的问题 急!!!请教JS的日期显示问题 自动显示下拉菜单问题 简单问题 你能行 Ext.ux.tree.TreeGrid如何加载解析xml数据 如何实现126邮箱的收件人的地址栏效果 javascrip 小问题
<html>
<body>
<input type="checkbox" name="C1" value="ON">
<input type="checkbox" name="C2" value="ON">
<input type="checkbox" name="C3" value="ON">
<input type="checkbox" name="C4" value="ON">
<input type="checkbox" name="C5" value="ON">
</body>
</html>
<head>
<title>采集模板生成模块</title>
<script type="text/javascript">
function checkAll(){
var checkArray = document.all("box");
for(i=0;i<checkArray[i];i++){
checkArray[i].checked=true;
}
}
</script>
</head>
<body>
<center>
<form name="ctcForm" action="" method="post">
<table id="Table" border=2>
<caption>
请选择部门所管辖的指标:
</caption>
<tr>
<th> </th>
<th align="center">指标编号</th>
<th align="center">指标名称</th>
</tr>
<tr>
<td>
<input type="checkbox" name="box">
</td>
<td>
<input type="checkbox" name="box">
</td>
<td>
<input type="checkbox" name="box">
</td>
</tr>
</table>
<br>
<table>
<tr>
<select id="ctcSelect">
<option value="atvdc">
年度目标值数据采集模板
</option>
<option value="mavdc">
每月完成值数据采集模板
</option>
</select>
</tr>
</table>
<br>
<table>
<tr>
<td>
<input type="button" name="buildModule" value="生成"
onClick="createModule();" />
</td>
<td>
<input type="button" name="allCheck" value="全选"
onClick="checkAll();" />
</td>
<td>
<input type="reset" name="reset" value="重置" />
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>全选的例子</title>
[code=JScript]
<script language="javascript">
/*
作者:Conis
时间:15:33 2007/12/12
功能:根据一个CheckBox的选择状态,将指定容器内的所有CheckBox都置为与些CheckBox相同的状态。一般用于点中一个CheckBox,全选/全取消一组CheckBox
限制:所有的目标CheckBox必需在同一个容器中
参数:
oContainer:包含CheckBox的容器
oCheckAll:全选的CheckBox,目标容器中所有CheckBox都会与这个CheckBox的Checked状态一样
*/
function SelectAllCheckBox(oContainer, oCheckAll)
{
var oList = oContainer.getElementsByTagName("INPUT");
if (oList && oList.length)
{
for(var i = 0; i < oList.length; i ++)
{
if (oList[i].type != "checkbox" || oList[i] == oCheckAll) continue;
oList[i].checked = oCheckAll.checked;
}
}
}
</script></head><body>
<table width="15%" border="0" cellspacing="0" cellpadding="0" id="tableOne">
<tr>
<td><input type="checkbox" name="checkAll" id="chkAllOne" onclick="SelectAllCheckBox(document.getElementById('tableOne'), this)"/></td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox2" id="checkbox2" />
<input type="text" name="textfield" id="textfield" /></td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox3" id="checkbox3" /></td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox4" id="checkbox4" /></td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox5" id="checkbox5" /></td>
</tr>
</table>
</body>
</html>
[/code]
function checkAll()
{
var checkArray = document.getElementsByName("box");
for(i =0; i < checkArray.length;i++)
checkArray[i].checked = true;
}
</script>
http://blog.csdn.net/lifeng_beijing/archive/2007/12/14/1936512.aspx
var bln = false;
function checkAll(chkname)
{
var checkArray = document.getElementsByName(chkname);
for(i =0; i < checkArray.length;i++)
if (!bln)
checkArray[i].checked = true;
else
checkArray[i].checked = false; bln = !bln;
}
</script>