Reference: In my Javascript I keep getting "submit is not a function". What did I do?
Developers often meet a javascript error that says "functionName() is not a function", even though functionName() is the actual function and coded correctly. That message usually comes up when functionName() is not defined.
How come does this happen? There is a secret. Shhhh~
1: <input2: type="button"3: id="btnCheck"4: name="btnCheck"5: onclick="javascript:btnCheck();" />6:7: <input8: type="button"9: id="btnCheck"10: name="btnCheck"11: onclick="javascript:checkSomething();" />
As seen above, there are two button controls. ID, name and onclick attribute on the first control are the same as each other. While as, the name attribute on the second control, is different from the onclick attribute.
The first one will not work and the second one will work. This is the secret. When an HTML tag calls javascript, the function name must be different from the control's ID and name; otherwise it displays the error "functionName() is not a function".
This is pretty basic understanding of using javascript. But sometimes developers overlook the basic. Let's back to basic! :-)

댓글을 달아 주세요
Thank you!
2009/12/14 12:10 [ ADDR : EDIT/ DEL : REPLY ]That fixed a problem that I had been battling for a few hours this morning!
What was odd with my problem is that is was working with everything named the same, then just suddenly stopped.
Many thanks!
No worries! I'm pleased at your comment that you eventually coped with your problem.
2009/12/15 21:22 [ ADDR : EDIT/ DEL ]