Chovy’s Blog

Javascript Error: submit is not a function

Tue, June 21, 2005 — Category: JavaScript

Javascript reserved word name collision when calling a form button “submit” and a function “submit”.

Took me a google search to find this one, but for some reason one of my forms was not submitting using javascript.

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”.

ie:


<input type="submit" name="submit" value="Login">

Change the name of the button to “login” or something else more reflective of it’s functionality instead of “submit”.
javascript:


function submitForm(formId) {
  var formObj = document.getElementById(formId);
  formObj.submit();
}

html:


<a href="http://www.homepage.com"
onclick="submitForm('loginForm'); return false">Login</a>

<form id="loginForm">
<input type="submit" name="login" value="Login">
</form>
  • Post Javascript Error: submit is not a function to del.icio.us
  • Post Javascript Error: submit is not a function to digg
  • Post Javascript Error: submit is not a function to Furl
  • Add Javascript Error: submit is not a function to YahooMyWeb
  • Simpify!
  • Post Javascript Error: submit is not a function to shadows
  • Post Javascript Error: submit is not a function to Spurl
  • Post Javascript Error: submit is not a function to BuddyMarks
  • Submit Javascript Error: submit is not a function to Slashdot

87 Comments »

329

Comment by Anonymous

July 12, 2005 @ 3:05 pm

loosely typed?! try NOT TYPED. thanks for the post. saved me some time in dicking with it.

330

Comment by Anonymous

July 15, 2005 @ 10:58 am

I feel especially stupid since I’ve actually had the same problem before.

331

Comment by Anonymous

July 19, 2005 @ 6:56 am

I was tearing my hair out on this, thanks!

332

Comment by Jon Lesser

July 20, 2005 @ 12:06 pm

I had a similiar problem when using a form button to call a function on click. The name of the button had to be different fro the function I was calling.

Did NOT work:
input type=”button” name=”newGame” value=”New Game” onClick=”newGame(); return false;”

Did work:
input type=”button” name=”New Game” value=”New Game” onClick=”newGame(); return false;”

The error in firefox’s console was “Error: newGame is not a function”

Thanks for the tip Chovy! You are the top hit when I google, “javascript error “is not a function”"

333

Comment by Lunamonkey

August 2, 2005 @ 3:07 am

This has been driving me f-in nuts all morning. Thanks!

334

Comment by Eric

August 2, 2005 @ 7:17 pm

*punches Javascript in the face*
Thank you very much for this info.

335

Comment by Anonymous

August 4, 2005 @ 7:50 am

yes thanks man, I also had a similair type problem - I had a function and it was calling the first time, but everytime after I was getting the error “userinfo is not a function” it turned out that the function name was clashing with some element id’s - strange but anyway, you need to be careful with the naming conventions!

336

Comment by Anonymous

August 10, 2005 @ 12:40 pm

Thanks for posting this. I never would have figured this out.

337

Comment by Mr Nico

August 10, 2005 @ 11:58 pm

Wow blogs are usefull! Amazing news. Well done Chovy!

338

Comment by Anonymous

August 16, 2005 @ 8:47 am

Yet another satisfied customer. I had this exact error. Thanks for posting useful information! :)

339

Comment by Brendan

August 26, 2005 @ 2:36 pm

You are my best friend FOREVER

340

Comment by Anonymous

August 30, 2005 @ 12:35 pm

I lost about 3 hours having this problem. Finally I found you post and I fixed it. Thanks man…

341

Comment by Anonymous

September 1, 2005 @ 7:52 pm

thank you! what an annoying error… thank god for bloggers. ;)

342

Comment by Anonymous

September 6, 2005 @ 10:40 pm

thx a lot for the hint!

343

Comment by Anonymous

September 9, 2005 @ 8:33 pm

hi, thanks a lot… it’s really work… i wasted half hour still not solve until found this page…:~~

344

Comment by Anonymous

September 12, 2005 @ 3:49 pm

awesome - i feel so dumb, but this has been tripping me up for a few days off and on. thanks for posting it! (you’re #1 result for “submit is not a function”)

345

Comment by Anonymous

September 14, 2005 @ 8:02 am

thanks!

346

Comment by Anonymous

September 19, 2005 @ 9:21 am

Thanks… Spend f**king day for this stupid error :p

347

Comment by Anonymous

September 19, 2005 @ 1:34 pm

I just spent the last 4 hours f’ing around with this issue. Thanks.

348

Comment by Dave

September 20, 2005 @ 12:29 pm

An office mate had this problem and then, immediately, I saw the same problem posted in the JavaScript forum at www.Tek-Tips.com. I Googled ‘JavaScript error submit’ and this was the first site that came up! Thanks a lot!

349

Comment by Moebius

September 26, 2005 @ 3:12 pm

Great, great post!
I spent a month searching for a solution !

350

Comment by Anonymous

October 3, 2005 @ 12:45 pm

Thanks for the post, I spent over an hour bashing my head against the wall before I bothered to Google it. Yours was the first result, and the only one I needed to look at.

351

Comment by Anonymous

October 6, 2005 @ 2:15 am

Thanks for this tip…saved me a lot of head scratching.

352

Comment by Anonymous

October 19, 2005 @ 12:20 pm

thank you so much for the tip. i have been baffled by this for a few days now and just decided to do a google on the error. fortunately your page popped up first and it took me directly to the answer!

thanks
Lura

353

Comment by Anonymous

November 11, 2005 @ 9:48 am

Godalmighty, thank you! This was baffling me!

354

Comment by Anonymous

November 17, 2005 @ 2:52 pm

You rock, thanks for posting this

355

Comment by chovy

November 17, 2005 @ 11:52 pm

I love providing the feeling of enlightenment :-D

(at least that’s how I felt when I finally figured it out).

425

Comment by Peter

December 12, 2005 @ 7:44 am

My god, thank you so much. Just another reason why I F’n hate JavaScript and it’s million and one quirks.

You’re a lifesaver. Thanks.

426

Comment by JustMe

December 14, 2005 @ 4:10 am

Wasted one hour and a half on this stupid thing.
Thanx alot for pointing this out. I also came here by firing “submit is not a function” against google.

434

Comment by Dennis

December 18, 2005 @ 5:12 pm

Dude, you are a savior! I spent almost an hour wrecking my brain about this. Thanks!

454

Comment by Jonathan Aquino

December 30, 2005 @ 4:13 pm

Add my name to the list of grateful people.

462

Comment by Michael Cooper

January 4, 2006 @ 4:04 am

Yep. I too battled away for about an hour on this one.
Thanks very much

468

Comment by row1

January 7, 2006 @ 4:54 pm

OMG thank you so much, I just spent the last hour trying to figure out what was wrong!!!

Comment by Irek Jozwiak

February 6, 2006 @ 3:49 am

Many thanks, man! You saved me a lot of time!

Comment by André Pinto

February 7, 2006 @ 11:14 am

You saved my, I had exactly the same problem! Thank You!!!!!!!!!!!!

André Pinto, Rio de Janeiro - Brasil

Comment by Kail Ceannai

February 9, 2006 @ 9:17 am

Thanks!

Comment by Andrew

February 9, 2006 @ 11:29 pm

Wow, thanks alot for the help!

Comment by DaFunky

February 10, 2006 @ 10:29 pm

Thanks!

I’ve been looking for hours before finding your tip.
I can sleep now :)

Comment by bjand

February 17, 2006 @ 3:29 pm

I had a similar problem.

Thanx to this blog, I noticed, that
You have to specify a different name to submit button.
for example:
will not work

will work

Comment by Kwun Yeung

February 18, 2006 @ 11:05 am

Thanks! You saved me! I spent hours figuring out what the “submit is not a function” means. Finally my codes are working now. I think I will even delete all useless names for the submit buttons to avoid this collision.

Comment by jtuxy

February 22, 2006 @ 11:26 am

Many thanx !

Comment by Pete O'Bryan

February 27, 2006 @ 9:40 am

I would like to be the forty-third person to thank you for publishing this discovery with such a googleable page title. BRILLIANT!!! I can go to lunch now.

Comment by Iwan

March 6, 2006 @ 2:27 am

Thanks for sharing, great job friend.
Hope to find other useful stuffs like this on your site.

Comment by Johs

March 9, 2006 @ 2:44 am

THANX!

Comment by Matt Wall

March 21, 2006 @ 8:45 am

Thanks heaps - been coding for 6+ years and that one stumped me for last 45mins!!

Comment by Gilbert

April 2, 2006 @ 5:24 pm

Thank you. A simple answer to a tricky problem. There is was, a button named form

Comment by Stellan Sjögren

April 4, 2006 @ 11:49 am

Thanks, I was going crazy on this thing

Comment by Uisce

April 7, 2006 @ 2:07 am

I’m feeling like a genius — only spent 15 minutes before I googled you up — thanks for the help!

Comment by Jevon

April 11, 2006 @ 2:18 pm

Thanks as well. That “feature” is totally lame. lol Javascript should be more strict!

Comment by MWarner

April 18, 2006 @ 10:12 am

Excellent! I just wasted over an hour on this. Many dozens of supposedly expert sites and NO HELP. Where do I send flowers?

Comment by Derek Basch

April 19, 2006 @ 9:21 am

I too wasted an hour of my life on this stupid error. I might as well go smoke 8 packs of Marlboros and waste a few more.

Comment by T Grove

April 25, 2006 @ 9:31 pm

This article is f***ing amazing, I should hire you at my company!! I have been searching all day for this stupid issue. And of course, with DOT syntax it blows my mind that IE supports this method. Submit is an object of the page, in DOT syntax it should be named differently. Thanks Again - you are a life savor!!

Now, how in the hell to you change all those other stupid f***ing posts on Google so they get it right???

Comment by haval

May 1, 2006 @ 5:59 am

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Comment by The Swede

May 5, 2006 @ 1:26 am

Thanx man. I just spent the last hour wondering why all funktions but submit() worked fine in my form. And there it was: a button named submit…

Comment by jeconais

May 14, 2006 @ 12:08 pm

Well, this’ll teach me to use google first rather than try and figure it out myself.

My wife thanks you for keeping my hair on my head, where it belongs.

Comment by Steve

May 14, 2006 @ 11:58 pm

Okay, it got me too. Put me down for 5 hours wasted on a Sunday night :)

I’m sure it was a good idea at the time, but what a hunk of junk HTML and JavaScript are. Thanks a bunch W3C. And no Bill Gates that doesn’t mean you are right, you don’t play well with others so you are completely invalid.

Comment by Wee Keat

July 12, 2006 @ 1:24 am

Thanks for that. Just saved me hours cause I would not have thought of a name clash!

Comment by Kevin

July 16, 2006 @ 12:34 pm

YOU SOLVED MY PROBLEM!

You rock!

Comment by chovy

July 16, 2006 @ 3:47 pm

You’re welcome!

Comment by Anonymous

July 19, 2006 @ 10:51 am

Thank you so much - that saved me a lot of time and frusteration - very very much obliged!

Comment by Mike

September 8, 2006 @ 3:16 pm

Thanks so much. I wasted a whole day on this, but I don’t think I’ll make that mistake again.

Comment by Ryan

September 18, 2006 @ 11:08 am

Count me as one of the ones you helped. I wasted at least a good hour of my life on this error!

Ryan

Comment by Ian

October 1, 2006 @ 5:24 am

I loooooooooooooooooooooooooooooooove you!

Comment by Avinash

October 2, 2006 @ 12:35 pm

gr888888888888 work dude………!!!

Comment by crazy

October 3, 2006 @ 1:55 pm

dude, you have no idea how much pain that problem caused me… Thanks a billion.

Comment by moty66

October 12, 2006 @ 5:55 am

Three hours of searchin my codes and javascripts books about this error, thank you so much, you haved my ***
moty

Comment by Anthony Ettinger

October 12, 2006 @ 11:07 am

I know - first thing I should’ve checked when I got the unexplainable was “reserved words”.

Comment by Ian Good

October 19, 2006 @ 9:16 am

Thanks for the tip! I spent an hour trying to figure it out before I googled it. I need to learn to google first.

Comment by jon

October 27, 2006 @ 3:46 pm

Thanks!! Luckily, I only lost 40 minutes before I found your incredibly useful article.

Comment by Marko Tulio corona Pacheco

November 7, 2006 @ 3:39 pm

Thanks man I love you,

from Mexico with love

It took me about 6 huurs to find your blog, Thanks again.It was so simple all time…

Marko Tulio corona Pacheco

Comment by TracyTrace

November 15, 2006 @ 10:17 am

Definitely worth googling this. I wasted about 30 minutes on this before finding your post. Thanks!

Comment by Oscar González

November 23, 2006 @ 10:09 am

Thanks!
Your article is very usefull; In Safari the error is
Object [object INPUT] (result of expression document.form1.submit) does not allow calls.

Comment by Coke

November 24, 2006 @ 4:00 am

I f$·%ing HATE JAVASCRIPT SO f$·%ing MUCH.

So incompatible, so weird, you can’t trace the source of the problem quick. Sucks, Sucks and don’t stop sucking.

Comment by chovy

November 24, 2006 @ 1:39 pm

COKE - why don’t you use the javascript debugger in Firefox? just type “javascript:” in the address bar, then reload the page.

Trackback by Cooldev.net

February 2, 2007 @ 7:18 am

2 fois la même erreur JavaScript, en 1 semaine !…

 Nommer un element par des noms de méthode d’objet JavaScript, c’est mal ! Par exemple, sur un formulaire avec soumission automatique :
<form action=”file.php” method=”get” id=”myForm”>
<select name=”myVar” onchange=”doc…

Comment by chovy

February 2, 2007 @ 10:36 am

my french isn’t all that great….and your example got truncated COOLDEV, so I’m not sure what you’re trying to show.

Comment by junktown

May 9, 2007 @ 11:05 am

Thanks, I was starting to get frustrated :)

Comment by r1tman

May 29, 2007 @ 11:00 pm

I had a submit button named submit and that is what totally jacked my submit code. So all 1001 ways I coded it would never work because document.formname.submit was an object and I guess it found that before finding the submit function? Not sure why but I know what the problem was at least!

- Rit

Comment by Tony

August 16, 2007 @ 1:36 pm

Thank you for this solution! I’ve been googling this issue for half an hour. Very helpful.

Comment by Jess

September 26, 2007 @ 3:47 pm

Thankyou! Ive been looking for hours for the reason why my javascript submit isnt working.

This is it. Thanks

Trackback by Compare lipitor and simvastatin.

October 12, 2007 @ 11:37 pm

Lipitor….

Lipitor….

Comment by Steven

October 26, 2007 @ 2:27 pm

Thanks a lot for providing this information.
It solved my problem.

Trackback by multiplayer poker game poker game simple three player poker game

November 15, 2007 @ 7:04 am

multiplayer poker game simple three player poker game poker game…

Précédemment poker table meilleures salles de jeux…

Trackback by sito poker

November 15, 2007 @ 7:13 am

casinos en ligne…

Piu” sito poker casino de paris…

Trackback by cash instant loan payday till cash loan payday

December 10, 2007 @ 6:33 am

free metro mp3 pcs ringtones…

That is the free lg ringtones verizon advance cash loan payday…

Trackback by mp3 ringer de graca

February 4, 2008 @ 3:12 am

download ringtone ceular gratis…

So far download ring celular grátis i730 nextel ringtones software…

Comment by szako

April 11, 2008 @ 2:34 pm

Thanks for this, i was going nuts. :-)

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

 
Keyword Advertisers:
SEO Directory SEO Links Free Link Directory Shopping Submission Directory Gardening Tips Political Forum Search Engine Optimization Search Engine Marketing Audio Video Directory SEO Forum Web Development Blog Organic SEO Wiki Web Development Consulting

Learn more about purchasing keyword text link ads on this site.