Development| HTML| JavaScript| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JavaScript submit method 
 

We can submit forms in following two ways in an HTML page

 

JavaScript submit method

                         

We can submit forms in following two ways in an HTML page:

  1. By using submit button 
  2. Submitting form programmatically using JavaScript. 

In this part of JavaScript methods tutorial we are going to describe you the second way of form submission i.e. submitting form programmatically using the JavaScript method "submit()". Syntax for using the submit() method is as follows :

Syntax:

 document.formname.submit();

Where formname is the name of the form which is to be submitted.

Description of code:

To illustrate the submit() method we have created a form named "frm". When we click on the link in this form, it calls the function submitForm() defined in the <script> tags. This function at last submits the form by calling submit() method with the form element reference object and simultaneously it moves to the "SuccessPage.html" as we have defined in the action attribute of the form tag. Full HTML code is as follows :

submitExample.html

<html>
 <head>
 <title>submit() method example</title>
 <script language="JavaScript">
	function submitForm()
	{
	  alert("Going to sbmit form");
	  document.frm.submit();
	}
 </script>
</head>
<body>
 <div style="background: #ff9900; width:'100%';"
       align="center">
  <font color="#0000ff" size="12pt">
	<b>submit() Example</b>
  </font>
 </div>
  <center>
    <form name="frm" action="SuccessPage.html">
      <p>Click on the following link to submit form</p>
      <a href="javascript: submitForm();">Submit Form</a>
    </form>
  </center>
 </body>
</html>

SuccessPage.html

<html>
 <head>
   <title>Submission success page</title>
 </head>
<body>
<div style="background: #ff9900; width:'100%';"
     align="center">
  <font color="#0000ff" size="12pt">
	<b>success page</b>
  </font>
 </div>
<center>
<p>Great ! You have submitted form successfully</p>
<a href="javascript:history.go(-1);">Go Back</a>
</center>
</body>
</html>

Output:

Click on the link "Submit Form" 

It goes to the SuccessPage.html as a result to the submission of form. We can also come back to the previous page by clicking on the link "Go Back".

Download Source Code

                         

» View all related tutorials
Related Tags: java javascript c attributes script reference object method sed remove ip attribute node move nat to ref e it alter

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.