Submit nameProperty
Submit Object
Definition and Usage
The name property sets or returns the value of the name attribute of the submit button.
The name attribute is used to transmit data to the server after form submission, or to reference form data in JavaScript.
Note:After form submission, only the name attribute of form elements will transmit data values.
Syntax
Set the name property:
submitObject.name="name"
Return the name property:
submitObject.name
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the name property
Example
Example
The following example shows the name of the submit button:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("submit1").name;
alert(x);
}
</script>
</head>
<body>
<form>
Email: <input type="text" id="email">
<input type="submit" name="submit1" id="submit1">
</form>
<button type="button" onclick="displayResult()">Show the name of the submit button</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("submit1").name;
alert(x);
}
</script>
</head>
<body>
<form>
Email: <input type="text" id="email">
<input type="submit" name="submit1" id="submit1">
</form>
<button type="button" onclick="displayResult()">Show the name of the submit button</button>
</body>
</html>
Try it yourself »
Submit Object Other Extensions