标题:gridview 中textbox 的判断
只看楼主
tianxbo
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2010-8-9
结帖率:80%
已结贴  问题点数:45 回复次数:3 
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
hhy420459674
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:203
专家分:179
注 册:2010-4-9
得分:23 
学习了!
2011-04-12 08:57
pengyouak
Rank: 2
等 级:论坛游民
帖 子:5
专家分:46
注 册:2011-3-30
得分:23 
可以加群,在线讨论。呵呵

编程技术高级交流群  139906551   欢迎加入讨论
2011-04-15 17:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-336215-1-1.html




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

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