A form is submitted when a user clicks a submit button (or link). This means the form is filled out and ready to be posted to the action source. However, there may be times when you would like to submit a form automatically such as when a timer runs out for a test.

Whatever the reason may be, JavaScript makes it easy to submit an HTML form automatically. Using the id of the form, you can use submit() to pragmatically submit the form.

How To Submit a Form Using JavaScript Automatically

Using submit, you submit a form like this:

document.forms["formid"].submit();

Easy huh?

Example Form and Submit

<form id="someform">
<textarea name="text"></textarea>
</form>

And submit it via JavaScript:

document.forms["someform"].submit();

This example JavaScript code shows how to submit a form when a hyperlink is clicked using the HTML from above:

<a href="javascript: document.forms['someform'].submit();">Submit this Form</a>

Feel free to post any questions you have![/cc]