Result of expression ‘document.forms[0].submit’ [[object HTMLInputElement]] is not a function.
I was trying to add a small delay into my form submission like so:
<form ... onsubmit="setTimeout('document.forms[0].submit()',2000);return false;">
but everytime I tried it, I got the following error:
Result of expression 'document.forms[0].submit' [[object HTMLInputElement]] is not a function.
This one had me stumped, until I realized what it was telling me… that my submit button was named “submit”.
<input type="submit" name="submit" id="Button1" />
I changed the name of the submit button and the problem went away.
<input type="submit" name="button1" id="Button1" />
Basically, Javascript provides a “convenience” by adding the names of the form inputs as children of the form. But this then clashes with preset function names, like the submit() function.
13 Comments
Permalink
Thanks, I had this exact problem. Googling for error messages saves the day.
Permalink
You are the man! I have been troubleshooting this for hours. It's always the simplest explanation. Thanks for pointing this out!
Permalink
Thank you for this post! I have been fighting this for about 20 minutes, until I saw this.
Permalink
It's not a matter of preset functions, because it happens with all LOADED functions, not the inline ones:
//script included:
function f() {
alert(“I'm going do submit”);
}
// html:
<form action=”f.html” id=”f” name=”f”>
<button onclick=”f()” type=”button”>GO</button>
This code runs in the same error (probably because DOM object's ids and function's names share same memory and the Javascript Engine returns the first occurrence, that's the DOM one).</form>
Permalink
It's not a matter of preset functions, because it happens with all LOADED functions, not the inline ones:
//script included:
function f() {
alert(“I'm going do submit”);
}
// html:
<form action=”f.html” id=”f” name=”f”>
<button onclick=”f()” type=”button”>GO</button>
This code runs in the same error (probably because DOM object's ids and function's names share same memory and the Javascript Engine returns the first occurrence, that's the DOM one).</form>
Permalink
Thank you. It is people like you that saves headaches when googeling error-messages, would have taken me forever without you <3
Permalink
You saved me from going insane with this problem. Thanks
Permalink
Seems like I run into this problem about once year and it is sites like this that save my ass.
Thank you!
Permalink
I was confused by this too..thanks..this really helped! James
Permalink
I'm glad it helped! – Thomas
Permalink
Thanks for posting this. Saved me a ton of time figuring out why my form was broken in Safari.
Permalink
It would have taken me forever to figure this out on my own. Thank you and thank google! 🙂Â
Permalink
You saved me a lot of searching – thank you!
Comments are closed.