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

141
Visualizações
The value in my number input won't change with user interaction

I am trying to multiply the value that the user will choose from the input box by an already set value of 0.1 but the value that is fetched from the input is either 0 or stays as the default value already set. The value (ex: 8) that is chosen by the user won't be taken as the new updated value.

This is the input:

<div>Number:<input type="number" id="NumberToMultiply" min="1" max="100" value="1"></input></div>

This is the script that is fetching the value inputted by the user:

var amount = document.getElementById("NumberToMultiply").value;

This is the line that is making the equation:

const Result = (amount)*(0.1)

The thing is that even if I chose the number "43" with the input, the value fetched from the input is still 1.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

var amount = document.getElementById("NumberToMultiply").value;
const Result = amount * 0.1;
console.log(Result);
document.getElementById("NumberToMultiply").oninput = function () {
    console.log(document.getElementById("NumberToMultiply").value * 0.1);
}

<div>Number:<input type="number" id="NumberToMultiply" min="1" max="100" value="1"></input></div>

That should do the trick, the problem was you didn't have any event on user trigger, just on load

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