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
T Grove
April 25, 2006 at 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???
haval
May 1, 2006 at 5:59 am
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
The Swede
May 5, 2006 at 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…
jeconais
May 14, 2006 at 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.
Steve
May 14, 2006 at 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.
Wee Keat
July 12, 2006 at 1:24 am
Thanks for that. Just saved me hours cause I would not have thought of a name clash!
Kevin
July 16, 2006 at 12:34 pm
YOU SOLVED MY PROBLEM!
You rock!
chovy
July 16, 2006 at 3:47 pm
You’re welcome!
Anonymous
July 19, 2006 at 10:51 am
Thank you so much – that saved me a lot of time and frusteration – very very much obliged!
Mike
September 8, 2006 at 3:16 pm
Thanks so much. I wasted a whole day on this, but I don’t think I’ll make that mistake again.
Ryan
September 18, 2006 at 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
Ian
October 1, 2006 at 5:24 am
I loooooooooooooooooooooooooooooooove you!
Avinash
October 2, 2006 at 12:35 pm
gr888888888888 work dude………!!!
crazy
October 3, 2006 at 1:55 pm
dude, you have no idea how much pain that problem caused me… Thanks a billion.
moty66
October 12, 2006 at 5:55 am
Three hours of searchin my codes and javascripts books about this error, thank you so much, you haved my ***
moty
Anthony Ettinger
October 12, 2006 at 11:07 am
I know – first thing I should’ve checked when I got the unexplainable was “reserved words”.
Ian Good
October 19, 2006 at 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.
jon
October 27, 2006 at 3:46 pm
Thanks!! Luckily, I only lost 40 minutes before I found your incredibly useful article.
Marko Tulio corona Pacheco
November 7, 2006 at 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
TracyTrace
November 15, 2006 at 10:17 am
Definitely worth googling this. I wasted about 30 minutes on this before finding your post. Thanks!
Oscar González
November 23, 2006 at 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.
Coke
November 24, 2006 at 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.
chovy
November 24, 2006 at 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.
chovy
February 2, 2007 at 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.
junktown
May 9, 2007 at 11:05 am
Thanks, I was starting to get frustrated :)
r1tman
May 29, 2007 at 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
Tony
August 16, 2007 at 1:36 pm
Thank you for this solution! I’ve been googling this issue for half an hour. Very helpful.
Jess
September 26, 2007 at 3:47 pm
Thankyou! Ive been looking for hours for the reason why my javascript submit isnt working.
This is it. Thanks
Steven
October 26, 2007 at 2:27 pm
Thanks a lot for providing this information.
It solved my problem.
szako
April 11, 2008 at 2:34 pm
Thanks for this, i was going nuts. :-)
Ash
November 20, 2008 at 11:05 am
Thanks! You saved my day!!!
You rock !!!!
DCE
January 27, 2009 at 8:29 am
thank god i did a search on it…lol. saved my life! Thanks
Srinivas
August 4, 2009 at 7:56 am
Hey!!
Thanks a lot yaar!! I spent a lot of my time in getting know the error!! Finally got the answer from you!! thanks a lot!! :)
Meru
November 11, 2009 at 5:42 am
Thank You So Much !!!
Jaime Navarro
November 19, 2009 at 12:31 pm
THANK YOU !!!!
Chris
November 19, 2009 at 11:04 pm
AWESOME ! Thank you. Just spent the last two hours trying to figure this one out!
ladokt
November 23, 2009 at 12:47 am
THANKS SO MUCH
robert
January 29, 2010 at 12:42 pm
dang it, i copied some code and it had a button named submit, and i spent
an hour trying to figure out why the heck my js was broken, thanks for the post
Jonatan
February 18, 2010 at 12:12 pm
Thanks men!!!!!!!!!
THE FORM-WIDGET COOKBOOK « ขุดคุ้ยเรื่องราว แบ่งปันประสบการณ์
March 17, 2010 at 7:11 am
[...] For reference on this: http://www.chovy.com/2005/06/21/1/javascri…not-a-function/ [...]
Marvelade
March 25, 2010 at 7:15 am
It’s not only a matter of reserved words, it’s also a matter of element naming conflicts that you do yourself.
Found out this after a good half hour of scratching my head:
will trigger a JS error “toggle_all is not a function” BECAUSE toggle_all is the name of the input element.
this code works:
because I set the name of the input element to something else than the function name.
Hope this saves somebody some time.
best regards,
Marvelade
Marvelade
March 25, 2010 at 7:17 am
HTML was stripped out of my previous message.
I’ll try to use HTML equivs:
< input type=”checkbox” name=”toggle_all” onclick=”toggle_all();” >
< input type=”checkbox” name=”toggle_everything” onclick=”toggle_all();” >
Ben
April 28, 2010 at 7:24 am
OMG THANK YOU SO MUCH! I searched high and low on Google and I finally found this article that saved my insanity. THANK YOU!
Shailesh Prajpati
June 25, 2010 at 9:21 am
I will just say about this article. – “Amazzing…” . I am PHP Web Developer and this article solved my problem of javascript….
Thanks Buddy
saeed
June 30, 2010 at 4:15 am
I am very much thankful to you for your lovely and informative post. It saved alot of my precious time..thank you ..
Eduardo Rodrigues
July 8, 2010 at 12:21 pm
Man,
thank you sooooo much!!!!!!
I´ve been over this for hours!!!
In debug, it would show the form as a form, with the submit method and all… but, error on the call. There was nothing poiting that the submit was being misplaced with the form button that had the same name.
You were a NINJA to find this out!
Thank you!!!!!!!!!!
chovy
July 8, 2010 at 1:01 pm
Thanks, glad I could help.