I have a page with a form and navigation links. If you click on a navigation link I need to submit the form as well as follow the navigation request.
To do this I have a link who’s href is pointing to the new page request and I have the onclick event bound to a function that submits the form on the page.
Could this scenario cause hard to reproduce problems of the form not submitting?
ex:
function submitForm(){
document.myform.submit();
}
<a href="page1.html" onclick="submitForm()">Back To page 1</a>
<form action="procsub" method="post"><input type="text" id="val1" /></form>
Submitting a form basically means reloading the page (targeting the same page, or a different one, as defined in the form). following a link is also a means of reloading the page.
what you could do would be to modify your submitForm function like so:
and
And then have the page that handles the form request, do the postback to whichever page was being passed as
redirectPage.A form submit is really not what the user expects when clicking ‘back to page 1’ tho. you may want to think this through one more time…