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

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

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