
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
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; }
- Related Articles
- HTML DOM Input Range autofocus property
- HTML DOM Input Range disabled property
- HTML DOM Input Range form property
- HTML DOM Input Range max property
- HTML DOM Input Range min property
- HTML DOM Input Range name property
- HTML DOM Input Range step property
- HTML DOM Input Range type property
- HTML DOM Input Button value Property
- HTML DOM Input FileUpload value Property
- HTML DOM Input Hidden value Property
- HTML DOM Input Month value Property
- HTML DOM Input Password value property
- HTML DOM Input Radio value Property
- HTML DOM Input Checkbox value Property
