• RSS Unknown Feed

    • An error has occurred; the feed is probably down. Try again later.
  • Meta

JavaScript: How to Submit a Form When a Button is Clicked

Submitting a form can be accomplished with JavaScript by accessing the named form and then calling the submit method on it.

<form name="frmTest" action="somepage.html”" method="post">
First Name: <input type=
"text" name="FirstName">
<input type=
"button" onclick="document.frmTest.submit();" value="Submit Form">
</form>

The JavaScript occurs with the onclick attribute of the button input type. It uses the document object model to access the named form and calls the submit method on it.

Leave a comment