The HTML Form Submit Button

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.

The code below creates a form submit button:

<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.

Identifying the submit button on the server side

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

Multiple Submit buttons

You can have more than one submit buttons in a form. But, how to identify from the server side which of the buttons was pressed to submit 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 :

  //Do update here..
  //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">

The server side code goes like this (PHP code):

if($_REQUEST['Operation'] == 'Update')
  //Do update here..
if($_REQUEST['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 using 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.

Comments on this entry are closed.

  • any bdy suggest me how i learn javascript

  • Greetings! Quick question that’s entirely off topic.
    Do you know how to make your site mokbile friendly?
    My webb site looks weird when viewing from myy apple iphone.
    I’m trying to find a theme or plugin that might be able too
    fix this problem. If you have any recommendations, pleasae share.
    Thank you!

  • Can you do this using javascript?

  • thanks for answers, but i have to change the confirm_box text as yes and no in place of ok and cancel..

  • I used your solution on my website. Thank you.

    • Hi,

      I want to create a form with HTML.. and put the 4 button on that form.. once we click on button. All appliciation should be open on by one..
      If you have any idea please let me know.

      I am able to open and one form ane one button with this coding but i do not know, how to create multiple botton o n one form..

      Please be adviosed.

  • Nice info….

  • Thank you.

  • Thank you! we’ve been working on creating a ‘member’ page and needed a form for log-in purposes. this answered several questions about submitting the form.

  • A note on the purpose of efficiency–
    In the multi-form-submit example above, you don’t need to perform an ’empty’ check.
    You can just check the existence of the variable and you’re good, which takes us from 9+ lines of code down to a mere 4 (assuming you have one line to execute):
    echo “Update!”;
    else if($_REQUEST[‘Insert’])
    echo “Insert!”;

    Hope that help somebody.

    • if($_REQUEST['Update'])
      will fail when $_REQUEST['Update'] is set to 0. The check for existence of a variable is isset($_REQUEST['Update']) The check to make sure that a variable exists (can be 0) and is not empty is !empty($_REQUEST[‘Update’]). There no inefficiency.

  • this site very use full for my web development diploma course

  • this site very use full for my web development diploma course

  • good

  • Hi!
    Great, but where do you put in the recipient’s address?

Previous Post:

Next Post: