w3resource logo


JavaScript Form Object - submit method

JavaScript Form Object : submit Method()

rating JavaScript Form Object : submit method() has average rating 10 out of 10. Total 1 users rated.

<<PreviousNext>>

Description

The submit() method of the form object is used to submit the specified form. It behaves the same as if a submit button was clicked.

Version

Implemented in JavaScript 1.0

Syntax

submit()

Parameter

None

Example of Form Object : submit method()

In the following web document submit method is used to submit a form.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>JavaScript form object - submit method example</title>
</head>
<body>
<h1 style="color: red">JavaScript form object : submit method</h1>
<h3> Click on the submit button to submit the form.</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function submitForm(form){
document.form1.submit(form);
}
//]]>
</script>
<form name = "form1"  method = "post"  action = "../../javascript/client-object-property-method/thankyou.html">
Input your name and address
<br /><br />
Name :  <input type="text" size="40" name="name" />
<br /><br />
Address : <input type="text" size="40" name="age" />
<input type="text" size="35" name="phone" />
<br /><br />
<input type= "button" value="Submit" onclick = "submitForm(this.form)" />
</form>
</body>
</html>

View the example of form object's submit method in the browser

Supported Browser

Internet Explorer 7 Firefox 3.6 Google Chrome 7 Safari 5.0.1 Opera 10
Yes Yes Yes Yes Yes

See also :

JavaScript Client side objects, methods, properties.

JavaScript Core objects, methods, properties.



<<PreviousNext>>