Need help with running total on row and column

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) }); ```
1 Like
<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>
1 Like

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

1 Like