【积累】根据CheckBox的不选中 ,用JQuery 清除 RidaoButtonList 的选中项
如题,项目要求无刷新更新数据。
1)Web页面布局 Html以及效果图
1 <asp:ListView ID="RoleSFGroupListView" runat="server" DataKeyNames="SFGroupCode" 2 EnableTheming="True" ClientIDMode="Static"> 3 <EmptyDataTemplate> 4 <table id="tbl_nodata" runat="server"> 5 <tr id="Tr1" class="selected" runat="server" > 6 <td id="Td1" runat="server"> 7 No data was returned. 8 </td> 9 </tr> 10 </table> 11 </EmptyDataTemplate> 12 <ItemTemplate> 13 <tr> 14 <td> 15 <asp:CheckBox ID="SFGroupCodeCheckBox" runat="server" Text='<%# Bind("SFGroupCode") %>' onclick="CheckBoxSFGroupCodeSelect(this)"/> 16 (<asp:Label ID="SFGroupNameLabel" runat="server" Text='<%# Bind("SFGroupName") %>' ></asp:Label>) 17 </td> 18 <td> 19 <asp:RadioButtonList ID="AccessRightRadioBtnList" runat="server" RepeatDirection="Horizontal" > 20 <asp:ListItem Text="Read only" Value="0"></asp:ListItem> 21 <asp:ListItem Text="Read and Edit" Value="1"></asp:ListItem> 22 </asp:RadioButtonList> 23 </td> 24 25 </tr> 26 </ItemTemplate> 27 <LayoutTemplate> 28 <table id="tbl_layout" runat="server" cellspacing="0" cellpadding="0" style="border-collapse: collapse;"> 29 <tr id="Tr1" runat="server"> 30 <td id="Td1" runat="server"> 31 <table id="tbl_item" runat="server" class="grid" border="0" style=""> 32 <tr id="Tr2" runat="server" class="selected"> 33 <th id="Th1" runat="server"> 34 <asp:Label ID="SFGroupNameLabel" Text="S&F Group" meta:resourcekey="SFGroupNameLabel" runat="server"></asp:Label> 35 </th> 36 <th id="Th2" runat="server"> 37 <asp:Label ID="ReadableDescriptionLabel" Text="Access Right" meta:resourcekey="ReadableDescriptionLabel" runat="server"></asp:Label> 38 </th> 39 40 </tr> 41 <tr id="itemPlaceholder" runat="server"> 42 </tr> 43 </table> 44 </td> 45 </tr> 46 </table> 47 </LayoutTemplate> 48 </asp:ListView>
|
2) jQuery代码 (需要自己添加jquery引用)
1 <script language="javascript" type="text/javascript"> 2 3 //obj--标签(CheckBox) 4 //ischecked--是否选中 5 function CheckBoxSFGroupCodeSelect(obj, ischecked) { 6 if (ischecked == undefined) { 7 ischecked = $(obj).attr("checked"); 8 } 9 //改变isreadable,iseditable状态 10 if (ischecked == false) { 11 var accessRightRadioName = $(obj).attr("name").replace("SFGroupCodeCheckBox", "AccessRightRadioBtnList"); 12 var accessRightRadio = document.getElementsByName(accessRightRadioName); 13 accessRightRadio[0].checked = false; 14 accessRightRadio[1].checked = false; 15 } 16 } 17 18 </script>
我百度了好久都没有找到想要的,我自己对js和jquery也不是很熟悉,所以分享出来给没有接触过的童鞋看看。^_^
漫漫人生,唯有激流勇进,不畏艰险,奋力拼搏,方能中流击水,抵达光明的彼岸