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

152
Views
Display Math calculation on a HTML Element with Javascript

I got the following code that calculates a percentage and I want to show the correct result on a html element (p). This is what I have but it's not displaying at all:

Here it is the code in my site: https://btrpay.com/btrpay-landing-dev/

enter image description here

<script>
var slider = document.getElementById("myRange");
var output = document.getElementById("demo");

output.innerHTML = slider.value;
slider.oninput = function() {
var slider = document.getElementById("myRange");
var savings = ( ( slider * 2.65 ) / 100 ) * 12;
output.innerHTML = this.value;
//document.getElementById("demo").value = savings;
}

Why is it not displaying and how can i print the result of the formula?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to set the output's innerHTML to the savings result:

output.innerHTML = savings;

Here is how the code snippet would change:

var slider = document.getElementById('myRange');
var output = document.getElementById('demo');

output.innerHTML = slider.value; // this will update the value based on slider
slider.oninput = function () {
    var slider = document.getElementById('myRange');
    var savings = ((slider * 2.65) / 100) * 12;
    output.innerHTML = savings; // this will update the value based on slider + calculation
};
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!