The HTML Form Submit Button

The basics of an HTML form submit button is discussed first in this article, moving towards more advanced topics like multiple submit buttons.

Note: If you are looking for a software tool for creating HTML forms quickly ( without even knowing HTML), see the article: How to make a web form and get it online quickly. This article contains more information about Simfatic Forms - an easy to use form creation software.

In order to create an HTML form submit button, you can use the HTML code below:
<input type="submit" name="mysubmit" value="Click!">

name: specifies the identification assigned to this submit button.
value: is the label that appears on the button.

The code above will create the submit button as shown below:

Identifying the submit button on the server side

The name and value of the button that is used to submit the form is passed along with the other data to the server script. For the button above, when you click on the submit button, the data passed to the server side script is mysubmit=Click!

Having Multiple Submit buttons

You can have more than one submit button in a form. But, how to identify from the server side which button submitted the form?

One way is to have different names for the submit buttons.

<input type="submit" name="Insert" value="Insert">
<input type="submit" name="Update" value="Update">

In the server side script you can do a check like this:
if(isset($Update))
{
  //Do update here..
}
else
if(isset($Insert))
{
  //Do insert Here
}

Note: The code depends on the server side scripting language you use. The code above is in PHP.

The second method is to have different values for submit buttons with the same name.

<input type="submit" name="Operation" value="Insert">
<input type="submit" name="Operation" value="Update">

and in the server side it could be handled like this:
if($Operation == "Update")
{
  //Do update here..
}
else
if($Operation == "Insert")
{
  //Do insert here
}

Switching the 'action' field dynamically

It is commonly required to switch the action field of the dynamically based on certain conditions.
Read: Switching HTML form 'action' field dynamically

How to submit a form on click of a hyperlink or an image?
Read: Tutorial on JavaScript Form Submit Methods

You can find more on HTML Forms in the HTML Form Tutorial

Using Simfatic forms, it is simple, quick & easy to create HTML forms. Click here for more info.

  • Digg
  • del.icio.us
  • Netscape
  • Reddit
  • StumbleUpon
  • Technorati
  • YahooMyWeb

How to make a form without coding? Click here for a demo.

Follow me on twitter

HTML Forms
HTML Form Tutorial
The Form Tag
The Form Submit Button
Form design software
How to make a web form
Make web forms quickly, without coding

Javascript Form Handling
  Basics
Using getElementById to get the elements in a form
Set value of form element using JavaScript
Get value of form element using JavaScript
Handling multiple forms using JavaScript
JavaScript reset/clear a form
  Advanced
JavaScript Form Validation
Submitting a form using JavaScript
Can JavaScript Email a Form?
Switching the form action field dynamically
JavaScript Button

JavaScript Popup Windows
The window.open method
The window.close method
More ...

 
.   Copyright © 2003-2009 JavaScript-coder.com. All rights reserved.