开发者

JQuery Calcuation - sum all the textboxes in a table column

I want to write a selector that gets me all the textboxes in a table column. So I can use this with Jquery Calculation to get a 'sum' box. I've written something based off this: Highlighting columns in a table with jQuery

Here's how far I've got: http://jsfiddle.net/Px78h/1/

The page loads, and I see my totals in the totalSum box. But updating any of the textboxes in the column seems to cause it to sum ALL the textboxes.

Am I doing something wrong?

Update: here's the 'end game' of what I was trying to do: http://jsfiddle.开发者_运维知识库net/Px78h/5/


This does not include totalSum input:

$("table. tbody > tr > td:nth-child(1) > input[name!='totalSum']").sum("keyup", "#totalSum");


You were including the totalSum field in your calcluation. Try

$("table tr > td:nth-child(1) > input:not(#totalSum)").sum("keyup", "#totalSum");

Either that or you make the totalSum not an <input> itself.

http://jsfiddle.net/Px78h/2/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜