Pure-Essence.Net

Javascript Error: submit is not a function

Posted by: pureessence on: October 15, 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>

5 Responses to "Javascript Error: submit is not a function"

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

Simply awesome!!! I was stuck with this and your solution helped..Thanks a lot

Thanks a lot. I was stuck with this problem for two weeks and tour solution was perfect for it.

Thanx a lot.. U saved my life !

thks. I came across this problem when dealing with asp.net (trying to apply a template)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

My most adorable Pomeranians

Categories

Archives

SocialVibe


Follow

Get every new post delivered to your Inbox.

Join 123 other followers