Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
Total increments unexpectedly in sum of fields

Dynamic added inputs each creates a total

Q. How can i reflect an accurate total of all totals from the inputs

(totals are the product of the first two columns/fields for each row)

When adding the totals, the total field is not incrementing for all fields as expected enter image description here the total at the bottom should show a sum of all totals from the table, yet is showing only the last total enter image description here

https://jsfiddle.net/ariia/g81kqro2/110/

$('body').on('change','.rowinput' , function(){
            var rowid=$(this).data('rowid');
           // alert(rowid);
             rowTotal(rowid);
          })
          
          function rowTotal(sumthis) {
        
            units = $('#row-'+sumthis+'-units').val()
            unitprice = $('#row-'+sumthis+'-unit-price').val()  
            rowtotal=units*unitprice
        
            $('#row-'+sumthis+'-total').val(rowtotal)
            invtotal(rowtotal)
        
          }
      function invtotal(totalz) {
           var totalx=0
            totalx = totalx+=totalz
        
        //alert(totalx)
        //return totalx
        $('#total>span').text(totalx)
      }

When placing the variable outside and not init to 0 each row, i get the desired effect with true totals, until i change the row total, say to a smaller total, the incorrect value then shows.

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!