Tutorial tools

How to submit a form using Javascript

Instead of using a button or image to submit a form, you might want to use a text link instead.

The code

HTML CODE

<form name="formname" action="script.php">
	<a href="#" onclick="document.formname.submit();">Submit form</a>
</form>

This uses the onclick event for the hyperlink to submit the form, the href must be set to # to stop the loading the link.