Javascript Error: submit is not a function
October 15th, 2008
Just my luck and I ran into the dreaded submit is not a function javascript error.
Here’s the scenario.
While coding javascript along, you get a form via id or name on your html page and calls the submit() function on it. You think it should just behave as expected (submits the form) instead nothing happens and in firebug, you get a submit is not a function error. You are like WTF is going on? You start to wonder if you remembered the syntax correctly so you do some research and all the pages tell you yes it’s just submit() and nothing else.
Finally you start to search on the error “submit is not a function” you get to this page and you learned:
The reason was the statement “formObj.submit();” in the javascript was colliding (resulting in ambiguity within the browser) with the form button, which was also named “submit”.
So just rename the element within the form tag that is named “submit” will fix the problem.
Here’s an example.
HTML:
<form id="search"><input name="something" /><input type="submit" name="submit" /></form>
Javascript:
function submitForm() {
document.getElementById('search').submit();
}
gives “submit is not a function” error.
Change HTML to:
<form id="search"><input name="something" /><input type="submit" name="NOT_SUBMIT" /></form>
2 Comments Leave a Comment
November 26th, 2008 at 11:14 pmSimply awesome!!! I was stuck with this and your solution helped..Thanks a lot


awesome solution.I had the same probem and ur answer just works
thanks