ASP.NET CheckBoxList 空间实现全选、反选、清除功能

    

View Code
 1 <script type="text/javascript" language="javascript">
2 function checkAll() {
3
4 for (var i = 0; i < document.getElementById("cblStatuteEnumTypeId").getElementsByTagName("input").length; i++) {
5
6 document.getElementById("cblStatuteEnumTypeId_" + i).checked = true;
7 }
8 }
9
10 function deleteAll() {
11
12 for (var i = 0; i < document.getElementById("cblStatuteEnumTypeId").getElementsByTagName("input").length; i++) {
13
14 document.getElementById("cblStatuteEnumTypeId_" + i).checked = false;
15 }
16 }
17
18 function ReverseAll() {
19
20 for (var i = 0; i < document.getElementById("cblStatuteEnumTypeId").getElementsByTagName("input").length; i++) {
21
22 var objCheck = document.getElementById("cblStatuteEnumTypeId_" + i);
23
24 if (objCheck.checked)
25
26 objCheck.checked = false;
27 else
28 objCheck.checked = true;
29 }
30 }
31
32 </script>

 

View Code
1 <asp:CheckBoxList ID="cblStatuteEnumTypeId" runat="server">
2 <asp:ListItem Value="1">不是废止依据</asp:ListItem>
3 <asp:ListItem Value="2">表格乱</asp:ListItem>
4 <asp:ListItem Value="3">缺表格</asp:ListItem>
5 <asp:ListItem Value="4">缺内容</asp:ListItem>
6 <asp:ListItem Value="5">废止人工识别</asp:ListItem>
7 <asp:ListItem Value="6">确定是修订依据</asp:ListItem>
8 <asp:ListItem Value="7">无法规标题清单</asp:ListItem>
9 </asp:CheckBoxList>


 

<input type="button" onclick="checkAll()" value="全选" />

 

 

<input type="button" onclick="ReverseAll()" value="反选" id="Button1" />

 

<input type="button" onclick="deleteAll()" value="取消" />
posted @ 2011-06-17 17:03  石 磊  阅读(3592)  评论(0编辑  收藏  举报