Easy Tutorial
❮ Prop Checkbox Name Jsref Statements ❯

Submit name Attribute


Definition and Usage

The name attribute sets or returns the value of the name attribute of a submit button.

The name attribute is used to send data to the server after form submission or to reference form data in JavaScript.

Note: Only the name attribute of form elements will pass data values after form submission.

Syntax

Set the name attribute:

Return the name attribute:


Browser Support

All major browsers support the name attribute.


Example

The following example displays the name of the submit button:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</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()">Display the name of the submit button</button>

</body>
</html>

❮ Prop Checkbox Name Jsref Statements ❯