
- 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 name property
The HTML DOM Input range name property is used for setting or returning the name attribute of an input range field. The name attribute helps in identifying the form data after it has been submitted to the server. JavaScript can also use the name attribute to refer form elements for manipulating later on.
Syntax
Following is the syntax for −
Setting the name property −
rangeObject.name = name
Example
Here, name is for specifying the range slider control name.
Let us look at an example for the range name property −
<!DOCTYPE html> <html> <body> <h1>Input range name Property</h1> <form> VOLUME <input type="range" id="RANGE1" name="VOL"> </form> <p>Change the name of the above range control by clicking the below button</p> <button type="button" onclick="changeName()">CHANGE NAME</button> <p id="Sample"></p> <script> function changeName() { document.getElementById("RANGE1").name ="VOLUME" ; document.getElementById("Sample").innerHTML = "Range control name is now VOLUME"; } </script> </body> </html>
Output
This will produce the following output −
On clicking the CHANGE NAME 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 CHANGE NAME that will execute the changeName() method when clicked by the user −
<button type="button" onclick="changeName()">CHANGE NAME</button>
The changeName() method uses the getElementById() method to get the input field with type range and set its name attribute value to “VOLUME” .This change is then reflected in a paragraph with id “Sample” and using its innerHTML property to display the intended text −
function changeName() { document.getElementById("RANGE1").name ="VOLUME" ; document.getElementById("Sample").innerHTML = "Range control name is now VOLUME"; }
- 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 step property
- HTML DOM Input Range type property
- HTML DOM Input Range value property
- HTML DOM Input Button name Property
- HTML DOM Input FileUpload name Property
- HTML DOM Input Hidden name Property
- HTML DOM Input Month name Property
- HTML DOM Input Number name Property
- HTML DOM Input Radio name Property
- HTML DOM Input Checkbox name Property
