As a newbie I'm trying to make a very simple email form work, but after hours and hours of lurking I still can't resolve it.
The problem is that firefox refuses to submit the form correctly while also clearing it, yet this works fine in Chrome and IE.
At the moment the code submits in all browsers, but doesnt clear in any of them. If I remove the "action" parameter
from the GetElementById it will submit and clear in Chrome / IE but not in Firefox.
Why are you calling submit() when it's going to be called automatically?
The moment you submit a form, the browser starts to load the 'action' url and there's no guarantee regarding what can or cannot happen subsequently on the current page.
If you want to submit form values without navigating to a new page, you can use an AJAX request, but the process will be script-dependent.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
The action parameter in the submit function is undefined, that's why Firefox gives an error and doesn't submit the form. If you want to pass form action to submit function you should write:
Thanks for the replies guys. I apologize for my lack of basic Javascript knowledge, but as I add "this.action" definition, it wont submit in Firefox, but will in Chrome. Using only "action" submits in Firefox too but doesnt clear...
If you mean the slash after target="_blank" then removing it didnt seem to change anything. Firefox still refuses to cooperate! Appreciate the help though
Well that clears fields fine in both browsers but it won't submit correctly in any for some reason ! =) Is there a way to also within the form call a seperate function that will use submit(action) etc? Maybe some onSubmit?
Thanks, but I'm sorry, just doesn't go through ...My script just doesn't let me submit the form correctly unless I use the onClick evenhandler, and if I do I still cant make Firefox clear the form after submission. I'm still lost..
Simple...and magic! That did it. Thanks a lot xelawho Really appreciate all other suggestions too, which I'm sure work fine in other contexts. I like beginning to learn javascript this way..
Bookmarks