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

118
Vistas
javascript - sum of values on input change

I'm modifying a draft website which is basically mde by storing data in local storage and fetching and rendering it. On the cart.html page input are created dynamically, depending upon how many packages are added in the cart.

There are 2 prices, one which is package's price (works totally fine) and the other one is Total price of all the items in cart, which doesn't seem to update and adds on values to the previous value. I'm not sure what I'm doing wrong but any help would be great!

I'm also attaching stackblitz to get better understanding of my application. Please readme if you want instructions

cart.html

        <div class="totalPrice">
            <table>
                <tr>
                    <td>Total Price</td>
                    <td id="totalPriceCount" data-total=""></td>
                </tr>
            </table>
        </div>
      

JS: (Don't really have idea how to achieve)

$(".myInput").on('input', function () {
            varCurrentVal = this.value;
            if (varCurrentVal == 0) {
                return;
            }
            var closestSibAttr = $(this).parent().parent().find("#quantityBasedPrice").attr("data-val");
            $(this).parent().parent().find("#quantityBasedPrice").html(varCurrentVal * closestSibAttr).attr("data-total", varCurrentVal * closestSibAttr);

// code to update #totalPriceCount to sum all the values into the Total Price
        })

Stackblitz: https://stackblitz.com/edit/web-platform-8cynxp?file=turkey.html

about 4 years ago · Santiago Gelvez
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