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:
» Can you please tell me how to put different validations on a textfield.???
» Reference a Field on a Form
» How to embed a data into an image ?
» Preloader gif or adsense that appears before the game loads
» How can I control a group of checkboxes with only 1 check?
» How to limit in real-time the number of characters in textarea with JavaScript?
» JavaScript random number?
» How to add a floating sidebar like on the Mashable website?

Tell a Friend


Developer Resources