# Need help with running total on row and column

**URL:** <https://forum.freecodecamp.org/t/need-help-with-running-total-on-row-and-column/348856>\
**Category:** General\
**Created:** [February 9, 2020, 8:10pm UTC](https://forum.freecodecamp.org/t/need-help-with-running-total-on-row-and-column/348856 "2020-02-09T20:10:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![msguna1dit](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@msguna1dit](https://forum.freecodecamp.org/u/msguna1dit)\
**Post date:** [February 9, 2020, 8:10pm UTC](https://forum.freecodecamp.org/t/need-help-with-running-total-on-row-and-column/348856/1 "2020-02-09T20:10:28Z")

</div>

Actually i need running total for row and column in same page. I am tried to use nth child function. The below code is working for row running total and now i need to add column total function. can some one help me with this.

````
   ```

````

 $ (document).ready(function() { $ ("tbody:nth-child(2) tr").each(function(){ var col1 = $ (this).find("td:nth-child(2) span span:nth-child(2)").find("input[type='text']"); var col2 = $ (this).find("td:nth-child(3) span span:nth-child(2)").find("input[type='text']"); var col3 = $ (this).find("td:nth-child(4) span span:nth-child(2)").find("input[type='text']"); setInterval(function(){ var num1 = 0; var num2 = 0; num1 = parseInt(col1.val(),10); num2 = parseInt(col2.val(),10); sum = num1 + num2; if( !isNaN(sum) ) col3.val(parseInt((num1 + num2),10)); },1) }); ```

---

<div class="post-metadata">

**Author:** ![msguna1dit](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@msguna1dit](https://forum.freecodecamp.org/u/msguna1dit)\
**Post date:** [February 9, 2020, 8:11pm UTC](https://forum.freecodecamp.org/t/need-help-with-running-total-on-row-and-column/348856/2 "2020-02-09T20:11:17Z")

</div>

```auto
<script>
  $ (document).ready(function() {
  
               $ ("tbody:nth-child(2) tr").each(function(){
 
                  var col1 = $ (this).find("td:nth-child(2) span span:nth-child(2)").find("input[type='text']");
                  var col2 = $ (this).find("td:nth-child(3) span span:nth-child(2)").find("input[type='text']");
                  var col3 = $ (this).find("td:nth-child(4) span span:nth-child(2)").find("input[type='text']");
                  
                  setInterval(function(){
                  
                                 var num1 = 0;
                                 var num2 = 0;
                                 num1 = parseInt(col1.val(),10);
                                 num2 = parseInt(col2.val(),10);
                                 sum = num1 + num2;
                                 if( !isNaN(sum) )
                                 col3.val(parseInt((num1 + num2),10));     
                  },1)
 
               });
       
});
</script>

```

---

<div class="post-metadata">

**Author:** ![msguna1dit](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@msguna1dit](https://forum.freecodecamp.org/u/msguna1dit)\
**Post date:** [February 9, 2020, 9:02pm UTC](https://forum.freecodecamp.org/t/need-help-with-running-total-on-row-and-column/348856/4 "2020-02-09T21:02:54Z")

</div>

Hi RandellDawson, could you help me how to dynamic column total using nth child or else any simple method?

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 7:36pm UTC](https://forum.freecodecamp.org/t/need-help-with-running-total-on-row-and-column/348856/5 "2021-06-01T19:36:49Z")

</div>

Closed on June 1, 2021, 7:36pm UTC


