Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

80
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda