实现全选以及分类全选。
在asp中,想实现点击总复选框,实现所有小类复选框全选,点大类的复选框,该大类下复选框全选。捣鼓了一天,也没弄出来,在这里请教高手。
函数f(),f1(),f2()各自怎么实现?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><!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=gb2312" /><title>无标题文档</title></head><body><form id="form1" name="form1" method="post" action=""><table width="479" height="53" border="1" cellspacing="0"><%for i=1 to 5%> <tr> <td width="488"><%=i%>.<input type="checkbox" name="checkbox" value="checkbox" onclick="f()"/> 全选该类</td> <%' 这里是大类复选框,点击实现该类下所有小类全选。%> </tr> <tr> <td> <div> <ul> <% for j=1 to 3 %> <li style="float:left; width:60px"><%=j%>. <input type="checkbox" name="checkbox2" value="checkbox" onclick="f1()"/></li> <% next %> </ul> </div> </td> </tr> <% next%> <tr> <td width="488" align="right"> <input type="checkbox" name="checkbox" value="checkbox" onclick="f2()"/> 全选 </td><%' 这里是总复选框,点击实现所有小类全选%> </tr></table></form></body></html>
<input type="checkbox" name="a">a3<br/>
<input type="checkbox" name="al" onclick="change('a',this)">aL<br/>
<input type="checkbox" name="b">b1<br/>
<input type="checkbox" name="b">b2<br/>
<input type="checkbox" name="b">b3<br/>
<input type="checkbox" name="bl" onclick="change('b',this)">bL<br/>
<input type="checkbox" name="all" onclick="change('all',this)">all<br/>
</body>
这样试试
[解决办法]
楼主把标签分组,就很好办了
<form id="form1" name="form1" method="post" action="">
<table width="479" height="53" border="1" cellspacing="0">
<%
for i=1 to 5
%>
<tr>
<td width="488"><%=i%>.<input type="checkbox" name="checkbox" value="checkbox" onclick="f('<%=i%>')"/>
全选该类</td> <%' 这里是大类复选框,点击实现该类下所有小类全选。%>
</tr>
<tr>
<td>
<div>
<ul>
<%
for j=1 to 3
%>
<li style="float:left; width:60px"><%=j%>. <input type="checkbox" name="chk_<%=i%>" value="checkbox" onclick="f1()"/></li>
<%
next
%>
</ul>
</div>
</td>
</tr>
<%
next
%>
<tr>
<td width="488" align="right"> <input type="checkbox" name="checkbox" value="checkbox" onclick="f2()"/>
全选 </td><%' 这里是总复选框,点击实现所有小类全选%>
</tr>
</table></form>
</body>
function f(id){
document.getElementsByName("chk_"+id); // 就是此类下面的所有复选框了
// 其它代码略
}