Can anyone help me
We call the submittion of a form through javascript, would anyone be able to explan why when the form is submitted, the onsubmit function in the form is completely ignored and we never get into this?
Thanks
Sarah
Printable View
Can anyone help me
We call the submittion of a form through javascript, would anyone be able to explan why when the form is submitted, the onsubmit function in the form is completely ignored and we never get into this?
Thanks
Sarah
I can't reall yhelp you with any code (just don't post anything huge). Here is how to submit using JS, this will do the same as pressing the submit button:
Code:<html>
<body>
<script type="text/javascript">
function submit_this_form() {
document.getElementById('myFrm').submit()
}
</script>
<form id="myFrm" action="myPage.cgi" method="post">
<input type="text" value="insert name here><br >
<input type="text" value="insert e-mail here><br >
<input type="button" value="submit (through JavaScript)" onClick="submit_this_form()">
</form>
</body>
</html>
Thanks for the reply
That bit works on but if i show you the top line to my form
<FORM onsubmit="return myOnSubmitEventHandler(); calculateCheckBoxes();" ID="searchFormID" action="res_results.asp" target="results" method=post style="display:inline">
The submit in the javascript ignores the two javascript functions that i would like to call
Any ideas?
Thanks
Sarah
maybe the function that calls the submitting of the form could run throught those functions first.
For now that is how i have implemented it
I was wondering if anyone has seen any documentation to support my theory that it will ignore this part of the function if submitting via javascript rather than through the enter button or a submit button on a form
Sarah
I haven't seen any documentation, but I can see why they would make it like that. since the function is called submit(), that's what it does, submit the form.
I think you'll have to keep it as it is, running the functions from the other one.
Just found this in MSDN
"The submit method does not invoke the onsubmit event handler."
As in the submit method via javascript
Thanks for all your help - nice to know you are not alone when trying to solve these problems
Sarah
Even if it worked, it wouldn't invoke the second function. The return prevents that.