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

154
Visualizações
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 Respostas
Responde à pergunta

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