The Submit name property

HTML DOM Submit name property The Submit object

Definitions and usages

The name property can set or return the name property value of the submit button.

The name property is used to transfer data to the server after the form is submitted, or to refer to the form data in Javascript.

Note: Only the name property of the form element passes the data value after the form is submitted.

Grammar

Set the name property:

submitObject.name=" name "

Returns the name property:

submitObject.name


Browser support

HTML DOM Submit name property HTML DOM Submit name property HTML DOM Submit name property HTML DOM Submit name property HTML DOM Submit name property

The name property is supported by all major browsers


The following example shows the name of the confirmation button:

<! DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
Online tutorials for W3Cschool (w3cschool.cn)
<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>
the name of the submission button is displayed with the name of the submit button, "button" onclick, "displayResult()".

</body>
</html>

Try it out . . .


HTML DOM Submit name property The Submit object