Home > DeveloperSection > Interviews > How to submit form without submit button?

Posted on    October-17-2011 12:15 AM

 JavaScript JavaScript 
 1 Answer(s)
  2391  View(s)
Rate this:

Chris Anderson
Chris Anderson

Total Post:197

Posted on    October-17-2011 12:00 AM

With this method, you can cause a form to be submitted when the user clicks on a regular link, which can be a text link or an image link.

This requires two steps.

First step, the form

Give your form a name. This is done in the FORM tag itself:


Second step, the JavaScript

Create a link containing the submit command

<a href="javascript:document.MyForm.submit();">
Click to submit the form

Optional third step

You can remove the submit button or, to be kind to the few non-JavaScript browsers that visit your site, put it between NOSCRIPT tags:

<input type="submit" name="Click here">

The above will display the submit button only when non-JavaScript browsers visit the page.

Don't want to miss updates? Please click the below button!

Follow MindStick