1
Oops, so... I have a value of an input type range that is being played in a span I want to take the value of that span with javascript, make a calculation with that span number and put in another span.
js code:
var parcela = document.getElementById('exibePercent').value;
var parcela1 = 4;
var result1 = parcela / parcela1;
document.getElementById("parcela1").value = result1;
html:
<span id="exibePercent">1000</span> <!---- SPAN QUE QUERO PEGAR O VALOR E JOGAR NO OUTRO SPAN---->
<span id="parcela1" value=""></span> <!----- SPAN QUE QUERO QUE RETORNE O VALOR DO RESULT DO JS ---->
I need the value of the new span to be automatically displayed, no button, as I can do?
– Tássio
Just leave the code "loose" and not within a function, I will create another example for you to see.
– Daniel Mendes
Another doubt I have is that the span "display" is dynamic, always change value, so the new span also has to be dynamic
– Tássio
I don’t know exactly what you want to do, but if you want the value to keep changing, you can use the function
setInterval, if the value should change when something "something else" changes, it may be possible to use the eventonchange.– Daniel Mendes
I have an input range type, it’s a loan simulator. The user defines the value of his loan that is played for the current exibePercent, hence with this value of the input, I want to define the value of the installments, dynamically.
– Tássio
So you can do it using
onchange, just create a function with the JS of the answer and put in theonchangewhere the user informs the value.– Daniel Mendes
I got it, thank you.
– Tássio