Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda