|
-
Feb 19th, 2004, 09:15 AM
#1
Thread Starter
Lively Member
Submitting forms through javascript
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
-
Feb 19th, 2004, 09:26 AM
#2
Frenzied Member
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>
Have I helped you? Please Rate my posts. 
-
Feb 19th, 2004, 09:28 AM
#3
Thread Starter
Lively Member
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
-
Feb 19th, 2004, 09:40 AM
#4
Frenzied Member
maybe the function that calls the submitting of the form could run throught those functions first.
Have I helped you? Please Rate my posts. 
-
Feb 19th, 2004, 09:41 AM
#5
Thread Starter
Lively Member
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
-
Feb 19th, 2004, 09:50 AM
#6
Frenzied Member
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.
Have I helped you? Please Rate my posts. 
-
Feb 19th, 2004, 09:51 AM
#7
Thread Starter
Lively Member
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
-
Feb 21st, 2004, 09:10 AM
#8
Even if it worked, it wouldn't invoke the second function. The return prevents that.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|