Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!