Helping ordinary people create extraordinary websites!

How do I submit a form by clicking on a link with JavaScript?

Wednesday, 16th September 2009
by cgiFX

How to submit a form using only a link rather than a submit button?

Hi cgiFX,
This bit of JavaScript is as simple as it is useful. For any website developer there must have come that point when they wanted to submit a form using a link. Below is the code:

Be sure to name your form for example:

<form name="testForm" ...

Use the below code for your link to submit the form. Notice where the name of the form is used.

<a href="javascript:document.testForm.submit();">Submit Me!</a>

- Magneto.

Monday, 21st September 2009

More JavaScript Help:
» When a form contains a field called action. How do you access the actual form.action?
» How can i control my check box?
» Encrypt the user inputted word with additional 3 letters?
» How can I convert characters to uppercase using JavaScript?
» Send mail to user when he had submitted data in database
» How to use Javascript to produce a dynamic population clock?
» Using Javascript to Create a new row
» How can I break up a string in JavaScript like explode in PHP?

Tell a Friend


Developer Resources