| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 593 人关注过本帖
标题:gridview 中textbox 的判断
取消只看楼主 加入收藏
tianxbo
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2010-8-9
结帖率:80%
收藏
已结贴  问题点数:45 回复次数:1 
gridview 中textbox 的判断
前台源码为:
  <asp:GridView id="gvNeedDrugs" runat="server"  Width="100%" AutoGenerateColumns="False">
    <Columns>
        <asp:BoundField DataField="jzd_id" ></asp:BoundField>
        <asp:BoundField HeaderText="名称" DataField="jzd_name" ></asp:BoundField>
        <asp:BoundField HeaderText="规格" DataField="jzd_guige" ></asp:BoundField>
        <asp:BoundField HeaderText="厂家" DataField="jzd_factory" ></asp:BoundField>
        <asp:BoundField HeaderText="所需数量" DataField="jzd_needno" ></asp:BoundField>
        
        <asp:BoundField HeaderText="单价" DataField="Jzd_onemoney" />
        <asp:TemplateField>
            <HeaderTemplate>
                捐助数量
            </HeaderTemplate>
            <ItemTemplate>
            
               <asp:TextBox ID="TextBox1" runat="server" Width="90px" Text="0" onclick="this.value=''" onBlur=""            
      onKeyUp="this.value=this.value.replace(/\D/g,'');" onafterpaste="this.value=this.value.replace(/\D/g,'');"></asp:TextBox>
            
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField HeaderText="已捐数量" DataField="jzd_nowno" ></asp:BoundField>
    </Columns>
    <HeaderStyle CssClass="tb_sxyp"  />
</asp:GridView>
   实现的功能是:
   在textbox 输入捐助数量后,判断此值是否大于所需数量-已捐数量,否则提示错误。重新输入。在触发onBlur事件时怎么编写js ?
搜索更多相关主题的帖子: asp 厂家 server False 规格 
2011-04-10 18:55
tianxbo
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2010-8-9
收藏
得分:0 

  function bs(t)
  {
     
      var d = 0;
      var a = 0;
      var inputs = document.getElementById("gvNeedDrugs").getElementsByTagName("input");
      var gridView = document.getElementById("gvNeedDrugs");
      var length = document.getElementById("gvNeedDrugs").rows.length;

          for (var i = 0; i <= inputs.length+2; i++)
          {
              if (inputs[i].type == "text") {
                 var vv;
                  if (i < 10) {
                      vv = '0' + (i+2).toString();
                  }
                  else {
                      vv = ''+(i+2).toString();
                  }
                  if (t.id == 'gvNeedDrugs_ctl' + vv + '_TextBox1') {
                     
                      var rows = gridView.rows[i+1];
                      d = rows.cells[4].innerText;
                      a = rows.cells[7].innerText;
                      if (t.value > d - a) {
                          alert('您捐助的数量超出!');
                          t.value = 0;
                      }
                  }
              }
         }
      }
解决了。发个代码。哈哈
2011-04-11 15:20
快速回复:gridview 中textbox 的判断
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035204 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved