全部選中

<html>
<head>
<title></title>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312' />
</head>
<body>
<script>

function select_all(form, s, sel)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name.substring(0, sel.length) == sel)
e.checked = s.checked;
}
}
</script>
<table width="500" border="1">
<form name="test_form" id="test_form">
<tr>
<td width="71"><label for="sel_all"><input type="checkbox" name="sel_all" id="sel_all" value="1"

οnclick="select_all(document.test_form, this, 'item_')"/>
全选</label></td>
<td width="413">title</td>
</tr>
<tr>
<td><input type="checkbox" name="item_1" value="checkbox" /></td>
<td>item 1</td>
</tr>
<tr>
<td><input type="checkbox" name="item_2" value="checkbox" /></td>
<td>item 2 </td>
</tr>
<tr>
<td><input type="checkbox" name="item_3" value="checkbox" /></td>
<td>item 3 </td>
</tr>
</form>
</table>


</body>
</html>

 

 

 

 

 

 

 

 

 

 

--------------------------------------------------------------------------------------------

 

 

 

 

<html>
<head>
<title></title>
<meta http-equiv='Content-Type' content='text/html; charset=big5' />
</head>
<script language="javascript">
function chkAll_onclick(){
if(typeof(form1.chkAccount) == "object"){
if(form1.chkAllAccount.checked){
SelAll();
}
else{
unSelAll();
}
}
}
function SelAll(){
var intCount;
        var result="";
if(form1.all("chkAccount").length > 1)
        {
for(intCount = 0; intCount < form1.all("chkAccount").length; intCount++)
                {
form1.chkAccount(intCount).checked = true;
                        result=result+form1.chkAccount(intCount).value+";";   
}
}
else{
form1.chkAccount.checked = true;
}

        alert("你選中的是:"+result);
}

function unSelAll(){
var intCount;
if(form1.all("chkAccount").length > 1)
        {
for(intCount = 0; intCount < form1.all("chkAccount").length; intCount++)
                {
form1.chkAccount(intCount).checked = false;
}
}
else{
form1.chkAccount.checked = false;
}
}
</script>
<body>
<form name="form1" method="post" action="">
<input name="chkAccount" type="checkbox" value="人民"/>人民
<input name="chkAccount" type="checkbox" value="中國"/>中國
<input name="chkAccount" type="checkbox" value="你好"/>你好
<input name="chkAccount" type="checkbox" value="公園"/>公園
<input name="chkAccount" type="checkbox" value="長江"/>長江
<input name="chkAccount" type="checkbox" value="黃河"/>黃河
<input type="checkbox" name="chkAllAccount" value="ON" title="全部選中" οnclick="chkAll_onclick()">全部選中

</form>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值