RSS
 

Javascript Error: submit is not a function

03 Aug

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:


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:

Login
VN:F [1.9.3_1094]
Rating: 9.0/10 (22 votes cast)
VN:F [1.9.3_1094]
Rating: +11 (from 11 votes)
Javascript Error: submit is not a function, 9.0 out of 10 based on 22 ratings
Retweet
 
 
  1. Anonymous

    July 12, 2005 at 3:05 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  2. Anonymous

    July 15, 2005 at 10:58 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  3. Anonymous

    July 19, 2005 at 6:56 am

    I was tearing my hair out on this, thanks!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  4. Jon Lesser

    July 20, 2005 at 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”"

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  5. Lunamonkey

    August 2, 2005 at 3:07 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  6. Eric

    August 2, 2005 at 7:17 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  7. Anonymous

    August 4, 2005 at 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!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  8. Anonymous

    August 10, 2005 at 12:40 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  9. Mr Nico

    August 10, 2005 at 11:58 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  10. Anonymous

    August 16, 2005 at 8:47 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  11. Brendan

    August 26, 2005 at 2:36 pm

    You are my best friend FOREVER

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  12. Anonymous

    August 30, 2005 at 12:35 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  13. Anonymous

    September 1, 2005 at 7:52 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  14. Anonymous

    September 6, 2005 at 10:40 pm

    thx a lot for the hint!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  15. Anonymous

    September 9, 2005 at 8:33 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  16. Anonymous

    September 12, 2005 at 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”)

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  17. Anonymous

    September 14, 2005 at 8:02 am

    thanks!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  18. Anonymous

    September 19, 2005 at 9:21 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  19. Anonymous

    September 19, 2005 at 1:34 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  20. Moebius

    September 26, 2005 at 3:12 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  21. Anonymous

    October 3, 2005 at 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.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  22. Anonymous

    October 6, 2005 at 2:15 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  23. Anonymous

    October 19, 2005 at 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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  24. Anonymous

    November 11, 2005 at 9:48 am

    Godalmighty, thank you! This was baffling me!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  25. Anonymous

    November 17, 2005 at 2:52 pm

    You rock, thanks for posting this

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  26. chovy

    November 17, 2005 at 11:52 pm

    I love providing the feeling of enlightenment :-D

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  27. Peter

    December 12, 2005 at 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.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  28. JustMe

    December 14, 2005 at 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.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  29. Dennis

    December 18, 2005 at 5:12 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  30. Jonathan Aquino

    December 30, 2005 at 4:13 pm

    Add my name to the list of grateful people.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  31. Michael Cooper

    January 4, 2006 at 4:04 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  32. row1

    January 7, 2006 at 4:54 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  33. Irek Jozwiak

    February 6, 2006 at 3:49 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  34. André Pinto

    February 7, 2006 at 11:14 am

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

    André Pinto, Rio de Janeiro – Brasil

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  35. Kail Ceannai

    February 9, 2006 at 9:17 am

    Thanks!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  36. Andrew

    February 9, 2006 at 11:29 pm

    Wow, thanks alot for the help!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  37. DaFunky

    February 10, 2006 at 10:29 pm

    Thanks!

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  38. bjand

    February 17, 2006 at 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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  39. Kwun Yeung

    February 18, 2006 at 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.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  40. jtuxy

    February 22, 2006 at 11:26 am

    Many thanx !

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  41. Pete O'Bryan

    February 27, 2006 at 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.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  42. Iwan

    March 6, 2006 at 2:27 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  43. Johs

    March 9, 2006 at 2:44 am

    THANX!

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  44. Matt Wall

    March 21, 2006 at 8:45 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  45. Gilbert

    April 2, 2006 at 5:24 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  46. Stellan Sjögren

    April 4, 2006 at 11:49 am

    Thanks, I was going crazy on this thing

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  47. Uisce

    April 7, 2006 at 2:07 am

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  48. Jevon

    April 11, 2006 at 2:18 pm

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

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  49. MWarner

    April 18, 2006 at 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?

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)
     
  50. Derek Basch

    April 19, 2006 at 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.

    VA:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.3_1094]
    Rating: 0 (from 0 votes)