Submit formProperty
Submit Object
Definition and Usage
The form property returns a reference to the form that contains the submit button.
If successful, this property returns a form object.
Syntax
submitObject.form
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the form property.
Example
Example
The following example will return the id of the form to which the submit button belongs:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("submit1").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Email: <input type="text" id="email">
<input type="submit" id="submit1">
</form>
<button type="button" onclick="displayResult()">Display the ID of the form it belongs to</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function displayResult(){
var x=document.getElementById("submit1").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Email: <input type="text" id="email">
<input type="submit" id="submit1">
</form>
<button type="button" onclick="displayResult()">Display the ID of the form it belongs to</button>
</body>
</html>
Try it yourself »
Submit Object Other Extensions