+ -
当前位置:首页 → 问答吧 → 请教!如何提取服务器控件Repeater里面的checkbox的个数呢?

请教!如何提取服务器控件Repeater里面的checkbox的个数呢?

时间:2011-12-21

来源:互联网

下面是我的代码

母版中:
<asp:Repeater ID="RpContent" runat="server">
  <HeaderTemplate>
  <table class="tlist" id="table1">
  <thead>
  <tr class="title">
  <asp:ContentPlaceHolder ID="Name" runat="server">
  </asp:ContentPlaceHolder>
  </tr>
  </thead>
  <tbody>
  </HeaderTemplate>
  <ItemTemplate>
  <tr>
  <asp:ContentPlaceHolder ID="ShowContent" runat="server">
  </asp:ContentPlaceHolder>
  </tr>
  </ItemTemplate>
  <FooterTemplate>
  </tbody> 
  </table>
  </FooterTemplate>
  </asp:Repeater>

具体的页面:
<asp:Content ID="Content3" ContentPlaceHolderID="Name" Runat="Server">
  <th>
  <input type="checkbox" id="btnSelectAll" runat="server" onclick="GetAllCheckBox(this);"/>
  </th>
  <th>序号</th>
  <th>登录用户</th>
  <th>登录时间</th>
  <th>退出时间</th>
  <th>Ip地址</th>
  <th>是否成功</th>
  <th>登录备注</th>
   
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ShowContent" Runat="Server">
  <th><input type="checkbox" id="btnSelect" runat="server" /></th>
  <th><%#Eval("LoginId")%></th>
  <th><%#Eval("UserInfo.UserName")%></th>
  <th><%#Eval("LoginTime")%></th>
  <th><%#Eval("LoginTime")%></th>
  <th><%#Eval("LoginUserIp")%></th>
  <th><%#Eval("IfSuccess")%></th>
  <th><%#Eval("LoginDesc")%></th>
</asp:Content>

其中<%#Eval("")%>是绑定数据!现在我要实现的效果就是提取我选中的checkbox的数量!但我用var checks = document.getElementsByName("btnSelect");提取的值为空,这是怎么回事呢?请前辈指点哈……

作者: lan_xiao_yin   发布时间: 2011-12-21

document.getElementsByName(name)它查询元素的 name 属性,而不是 id 属性。

作者: yzjszl   发布时间: 2011-12-21

相关阅读 更多

热门下载

更多