关闭

GridView JavaScript HtmlInputChecBox

296人阅读 评论(0) 收藏 举报
 JavaScript:
    <script language="javascript">
   var SelectCount=0;
    function slcNo_click(sender,selectCount)
{
//alert(selectCount);
SelectCount=selectCount;
var count=0;
var   chkother=   document.getElementsByTagName("input");
for(i=0;i<chkother.length;i++)
{
  if(   chkother[i].type=='checkbox') 
  {
 if(chkother[i].checked)
 {
   count++;
 }
 if(count>selectCount)
{
sender.checked=false;
alert("选择数不能大于3");

}

}
}

}
function Check()
{

//alert(SelectCount);
//return false;
var count=0;
  var   chkother=   document.getElementsByTagName("input");
 for(i=0;i<chkother.length;i++)
{
  if(   chkother[i].type=='checkbox') 
  {
     if(chkother[i].checked)
 {
   count++;
 }
  }
}
  if(count<SelectCount)
  {
  alert("入围数不够!");
  return false;
  }
  else if(count==SelectCount)
  {
  return true;
  }
}
    </script>


.aspx:

        <asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="False" CellPadding="2" ForeColor="#333333" GridLines="None" Width="100%" OnRowDataBound="GridView2_RowDataBound" CellSpacing="1" AllowPaging="True" PageSize="15" OnPreRender="GridView2_PreRender">
        <Columns>
            <asp:TemplateField HeaderText="投票">
                <ItemTemplate>
   
                    <input id="checkboxname" runat="server" name="checkboxname" type="checkbox" />
                    <asp:HiddenField ID="hidden_id" runat="server" Value='<%#Eval("BallotedMedicineID") %>' />
                   
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:TemplateField>
        <asp:BoundField DataField="MedicineName" HeaderText="药品名" >
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
        </asp:BoundField>
          <asp:BoundField DataField="CurrencyName" HeaderText="通用名" >
              <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="150px" />
          </asp:BoundField>
          <asp:BoundField DataField="DrugFormName" HeaderText="剂型" >
              <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
          </asp:BoundField>
          <asp:BoundField DataField="StandardName" HeaderText="规格" >
              <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
          </asp:BoundField>
          <asp:BoundField DataField="QualityLevelName" HeaderText="质量层次" >
              <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
          </asp:BoundField>
 
           <asp:TemplateField HeaderText="厂家信息">
            <ItemTemplate>
                <asp:LinkButton ID="btn_viewEnterprise" runat="server"><%#Eval("EnterpriseName") %></asp:LinkButton>

          <asp:HiddenField ID="hidden_eid" runat="server"  Value='<%#Eval("EnterpriseID") %>'/>
            </ItemTemplate>
               <ControlStyle ForeColor="Navy" />
          </asp:TemplateField>
        </Columns>
               <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
               <RowStyle BackColor="#EFF3FB" Font-Size="9pt" Font-Names="宋体" ForeColor="Navy" />
               <EditRowStyle BackColor="#2461BF" />
               <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
               <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" Font-Names="宋体" Font-Size="9pt" />
               <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Size="10pt" />
               <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:4139次
    • 积分:95
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档