Submitting A HTML Form Using JavaScript
Published by philipnorton42 on Thu, 06/19/2008 - 15:29In order to submit a form using an event you need to run a click event on any submit button in the form. Take the following form.
1 2 3 4 | <form method="post" onsubmit="alert('Form submitted!'); return false;">
<input type="text" name="testvalue" value="" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form> |
To run a submit event using JavaScript we just find the submit button via the id and run click() against it.
document.getElementById('submit').click();
That's it!
Category:
Add new comment