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

196
Vistas
Change value based on Closure Counter in JavaScript

How to change the Total price value based on No. of boxes value.

the code I tried

function NegboxENtryValue() {
  let inputval = document.getElementsByClassName("boxENtryValue")[0].value
  let prodPrice = document.getElementById("productTotalPrice").innerHTML.split(/[\s&]+/)
  prodPrice[1] = prodPrice[1] / inputval
  document.getElementById("productTotalPrice").innerHTML = `Rs. ${prodPrice[1]} /-`
}

function PosboxENtryValue() {
  let inputval = document.getElementsByClassName("boxENtryValue")[0].value
  let prodPrice = document.getElementById("productTotalPrice").innerHTML.split(/[\s&]+/)
  prodPrice[1] = prodPrice[1] * inputval
  document.getElementById("productTotalPrice").innerHTML = `Rs. ${prodPrice[1]} /-`
}

where boxENtryValue is the value of no. of boxes. its working, but when decrease to 1, the value doesnt change, still on x2 value.

Note: Total price should be multiplication or division of Price/Box

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

  function NegboxENtryValue() {
         let inputval = document.getElementsByClassName("boxENtryValue")[0].value
         let prodPrice = document.getElementById("productPrice").innerHTML.split(/[\s&]+/) // here use product price not product total price
         prodPrice[1] = prodPrice[1] * inputval
         document.getElementById("productTotalPrice").innerHTML = `Rs. ${prodPrice[1]} /-`
       }

function PosboxENtryValue() {
      let inputval = document.getElementsByClassName("boxENtryValue")[0].value
      let prodPrice = document.getElementById("productPrice").innerHTML.split(/[\s&]+/) // here use product price not product total price
      prodPrice[1] = prodPrice[1] * inputval
      document.getElementById("productTotalPrice").innerHTML = `Rs. ${prodPrice[1]} /-`
    }

Please use product price in the calculation.

about 4 years ago · Juan Pablo Isaza Denunciar
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