
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Range value property
The HTML DOM Input range value property is associated with the input element having type=βrangeβ and the value attribute. It is used to return the value of slider control value attribute or to set it. The value attribute can be the default value or the value set by dragging the slider.
Syntax
Following is the syntax for β
Setting the value property β
rangeObject.value = text;
Here, text is used for specifying the value for the range slider control.
Example
Let us look at an example for the input range value property β
<!DOCTYPE html> <html> <body> <h1>Input range Value property</h1> <form> VOLUME <input type="range" id="RANGE1" name="VOL"> </form> <p>Get the above element value by clicking the below button</p> <button onclick="getValue()">Get Value</button> <p id="Sample"></p> <script> function getValue() { var t = document.getElementById("RANGE1").value; document.getElementById("Sample").innerHTML = "The value for the radio button is : "+t; } </script> </body> </html>
Output
This will produce the following output β
On clicking the βGet Valueβ button β
In the above example β
We have created an input field contained inside a form having type=βrangeβ, id=βRANGE1β, name=βVOLβ β
<form> VOLUME <input type="range" id="RANGE1" name="VOL"> <form>
We have then created a button βGet Valueβ that will execute the getValue() method when clicked by the user β
<button type="button" onclick="getValue()">Get Value</button>
The getValue() method gets the input element using the getElementById() method and assigns its βvalueβ attribute value to variable t. This variable is then displayed in the paragraph with id βSampleβ using its innerHTML property β
function getValue() { var t = document.getElementById(βRANGE1").value; document.getElementById("Sample").innerHTML = "The value for the input field is : "+t; }