jQuery文本框的总和. [英] jQuery Sum of text boxes.

查看:84
本文介绍了jQuery文本框的总和.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.我有一个包含文本框的ASP.Net GridView.我要添加页脚,其中包含同一列的总和,并且在每一行的末尾还有一个求和字段.在不同的报告中,行数可能有所不同,但列是固定的.
这是jsFiddle http://jsfiddle.net/dUa85/21/ [

Hi. I have an ASP.Net GridView which contains textboxes. I am going to add footer where it contains the sum of the same column and at the end of each row also a sum field is there. The number of rows may be vary in different report, but the columns are fixed.
Here is the jsFiddle http://jsfiddle.net/dUa85/21/[^] where it contains the html output. I was able to get near to what i expected, but the keystrokes are also getting counted. Please try to add values under Jan textboxes to get the problem duplicated.

Any solution? If more details are needed, please let me know.

Thank you for your time.

推荐答案

这里的问题是您月份总计的ID也像您的商品一样具有相同的前缀txtJan .有多种方法可以解决此问题.最简单的方法是将total字段的前缀更改为其他名称-在这种情况下,我只是将其更改为txtItemJanTotal.我已经分叉了您的小提琴,并在那里解决了此问题.看看吧!

http://jsfiddle.net/nXT7k/ [ ^ ]

另一种方法是,在您的
The issue here is the id''s of your month totals also have the same prefix of txtJan just like your items. There are multiple ways to fix this. Simplest is to change the prefix of the total field to something else - in this case I just changed it to txtItemJanTotal. I have forked your fiddle and fixed the issue there. Check it out!

http://jsfiddle.net/nXT7k/[^]

Another way is, during your


.每次循环期间,使用正则表达式检查id的格式是否为txtJan [0-9].

希望这会有所帮助!
.each looping, check if the id is of the format txtJan[0-9] using Regex.

Hope this helps!


这篇关于jQuery文本框的总和.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆