js gridview 循环计数

function clearNoNum(obj)
                        {
                         //先把非数字的都替换掉,除了数字和.
                         obj.value = obj.value.replace(/[^/d.]/g,"");
                         //必须保证第一个为数字而不是.
                         obj.value = obj.value.replace(/^/./g,"");
                         //保证只有出现一个.而没有多个.
                         obj.value = obj.value.replace(//.{2,}/g,".");
                         //保证.只出现一次,而不能出现两次以上
                         obj.value = obj.value.replace(".","$#$").replace(//./g,"").replace("$#$",".");
                         doFor(7);
                        }
                        function  check(obj)  
                        {  
                            var   regx=/^([-]?)([0-9]+)((.[0-9]{2})?)$/;  
                            var   m=regx.test(obj.value);  
                            if(obj.value!='')
                            {
                                if(m==true)  
                                {  

                                }  
                                else  
                                {  
                                alert("输入格式不正确,/r/n请输入整数/负数.");  
                                obj.value='0';
                                }
                                doFor(5); 
                            }
                        }
                        function doFor(j)
                        {
                             var table=document.getElementById("<%=GridView2.ClientID%>");
                             var tr=table.getElementsByTagName("tr");
                             var sum=0;
                             for( i=1;i <tr.length-1;i++)
                            {
                                 var a=0;
                                 if(tr[i].getElementsByTagName("td")[j].getElementsByTagName("input")[0].value.length!=0)
                                 {
                                    a=parseFloat(tr[i].getElementsByTagName("td")[j].getElementsByTagName("input")[0].value);
                                 }  
                                else
                                {
                                    a=0;
                                }
                                sum+=a;
                            }
                            tr[tr.length-1].getElementsByTagName("td")[j].getElementsByTagName("input")[0].value = sum;
                            tr[tr.length-1].getElementsByTagName("td")[j].getElementsByTagName("input")[0].readonly = true;
                        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值