Dave's Brain

Browse - Programming Tips - How can I programatically submit an HTML form?

Date: 2009nov9
Language: javaScript

Q.  How can I programatically submit an HTML form?

A.  Call the form's submit method.  If you only have one form:

function submitTheForm() { if (document.forms.length == 0) return false; document.forms[0].submit(); return true; }
If you have multiple forms:
<form id=the_second_form> </form> <script> function submitSecondForm() { var obj; obj = document.getElementById('the_second_form'); obj.submit(); } </script>

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.