Javascript Reference - HTML DOM Input Range name Property








The name property sets or gets the name attribute of a slider control.

The name attribute identifies form data after it has been submitted to the server.

We can also use the name value to reference form data using JavaScript on the client side.

Browser Support

name Yes 10.0 Yes Yes Yes

Syntax

Return the name property.

var v = rangeObject.name

Set the name property.

rangeObject.name=name




Property Values

Value Description
name Specifies the name of the slider control

Return Value

A String type value representing the name of the slider control.

Example

The following code shows how to change the name of a slider control.


<!DOCTYPE html>
<html>
<body>
<!--from  w w w  .  j a v  a  2 s .c om-->
<input type="range" id="myRange" name="points">
<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<script>
function display() {
    var x = document.getElementById("myRange").name;
    console.log("The name is: " + x);
}

function change() {
    var x = document.getElementById("myRange").name = "newRangeName";
    console.log("The name was changed to: " + x);
}
</script>

</body>
</html>

The code above is rendered as follows: