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! :-)



RSS2 Feed