CancelImage Upload

How to submit a form via a link with JavaScript

The standard HTML form submit button is all well and good. But as soon as you start working on more complex web applications you will probably sooner, rather than later, require a JavaScript function via which a specified form can be submitted. Here then is just that function:


As you can see the specified form1 is accessed via getElementById(), and then submitted with the function submit(). Here is an example of how this code can be used in practice:

<title>How to submit a form via a link with JavaScript</title>

<form id="form1">
Title: <input type="text"><br>
Text: <textarea></textarea><br>

<a href="javascript:document.getElementById('form1').submit();">Submit Form1</a>


Want to leave a comment?

No problem. Just enter your email and password below.

register | home | reminder

myDesignTool Networking •