javascript - How to sum input fields row and column -


I have searched a lot and there is no solution, and since my code capabilities are somewhat limited , I ask for help.

What I am trying to do is actually found here:

  $ (function () {var $ iTableTotals = $ ("# iTable .colotal "); Var $ eTableTotals = $ (" # eTable .colotal "); var $ diffValues ​​= $ (" .diffValue "); $ (". ColTotal "). ('Change keyboard', function () { $ ITableTotals.each (function (i) {var diff = number ($ iTableTotals.eq (i) .val ()) - number ($ eTableTotals.eq (i) .val ()); $ diffValues.eq (i) .val (difference));});}); $ ITableTotals.eq (0) .change ();});  

But I want to input field instead of preloaded numbers. To clarify, I found this code on the Web, I am not the author of this code.

Thank you.

Surely 100% is not sure that instead of pre-loaded numbers What is meant by the input field, please see that FOKED BEDLAL, hopefully what it means:

HTML:

  & lt; Table id = "sum_table" width = "300" border = "1" & gt; & Lt; Tr class = "titlerow" & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; Apple & lt; / TD & gt; & Lt; TD & gt; Orange & lt; / TD & gt; & Lt; TD & gt; Watermelon & lt; / TD & gt; & Lt; TD & gt; Strawberry & lt; / TD & gt; & Lt; Td> By line & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; ROW1 & lt; / TD & gt; & Lt; Td class = "rowAA" & gt; & Lt; Input value = "7" /> gt; & Lt; / Td> & Lt; Td square = "row aAA" & gt; & Lt; Input value = "2" /> gt; & Lt; / Td> & Lt; Td class = "rowBB" & gt; & Lt; Input value = "3" /> gt; & Lt; / Td> & Lt; Td class = "rowBB" & gt; & Lt; Input value = "4" /> gt; & Lt; / Td> & Lt; Td square = "total rave" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; ROW2 & lt; / TD & gt; & Lt; Td class = "rowAA" & gt; & Lt; Input value = "1" /> & Lt; / Td> & Lt; Td square = "row aAA" & gt; & Lt; Input value = "2" /> gt; & Lt; / Td> & Lt; Td class = "rowBB" & gt; & Lt; Input value = "3" /> gt; & Lt; / Td> & Lt; Td class = "rowBB" & gt; & Lt; Input value = "4" /> gt; & Lt; / Td> & Lt; Td square = "total rave" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Row3 & lt; / TD & gt; & Lt; Td class = "rowAA" & gt; & Lt; Input value = "1" /> & Lt; / Td> & Lt; Td square = "row aAA" & gt; & Lt; Input value = "5" /> gt; & Lt; / Td> & Lt; Td class = "rowBB" & gt; & Lt; Input value = "3" /> gt; & Lt; / Td> & Lt; Td class = "rowBB" & gt; & Lt; Input value = "4" /> gt; & Lt; / Td> & Lt; Td square = "total rave" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; Tr class = "totalColumn" & gt; & Lt; Td square = "total call" & gt; & Lt; / Td> & Lt; Td square = "total call" & gt; & Lt; / Td> & Lt; Td square = "total call" & gt; & Lt; / Td> & Lt; Td square = "total call" & gt; & Lt; / Td> & Lt; Td square = "total call" & gt; & Lt; / Td> & Lt; Td square = "total call" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; Javascript:  
  Function UpdateTotal () {$ ("# sum_table tr: not (: first, last: last) td: last-child") .text (function () {var t = 0; $ (this) .prevAll (). Find ("input"). (Function () {t + = parseInt ($ (this) .val (), 10) 0;}); Returns t;}); $ ("# Sum_table tr: last td: not (: first, last:") Text (function (i) {var t = 0; $ (this) .Parent (). PrevAll (). Find ("td: Nth-child" (+ + (i + 2 +) "input.) Each (function () {T + = parseint ($ (this) .val (), 10) || 0;}); return "total:" + t;});} $ ("input") .change (updateTotals); The sum up to today ();  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -