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

145
Vistas
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 Respuestas
Responde la pregunta

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 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