Getting range input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Getting range input?

How do I get the values from range inputs and display them? https://code.sololearn.com/Wixe86wt1l59/?ref=app You can edit this however you need to. I understand all of the html involved with range inputs.

27th Jul 2018, 7:09 AM
Daniel Cooper
Daniel Cooper - avatar
5 Answers
0
I can't get the code playground to work for me, so I'll put the solution here. You need JS to get the value of a range input and display it. HTML: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <input type="range" id="input"> <input type="submit" onclick="output()"> <div id="output"></div> </body> </html> JS: function output() { document.getElementById("output").innerHTML = document.getElementById("input").value }
27th Jul 2018, 8:06 AM
apex137
apex137 - avatar
0
Is there a way to make it update live(as it moves)?
27th Jul 2018, 8:17 AM
Daniel Cooper
Daniel Cooper - avatar
0
You'll need an eventListener. Check this guy's code: https://codepen.io/juanbrujo/pen/uIqaw
27th Jul 2018, 8:36 AM
apex137
apex137 - avatar
0
Change to <input type="range" onchange=" document.getElementById('output').innerText = this.value"> or <input type="range" onchange="this.nextElementSibling.innerText = this.value"> https://code.sololearn.com/W1GAyFvNViDS/?ref=app
27th Jul 2018, 10:53 AM
Calviղ
Calviղ - avatar
0
https://code.sololearn.com/WCJDKoBMQIvk/?ref=app How's this guys?
27th Jul 2018, 6:30 PM
Daniel Cooper
Daniel Cooper - avatar