Form submit from JavaScript
Be careful: if you want to submit a form from Javascript using something like
this.form.submit();
or
document.forms[ myFormName ].submit();
and it gives you a nasty error like
submit is not a function
don’t despair, just:
- look at the HTML source code:
<input id="submit" name="submit" value="Send to developer" type="submit" />
- change the name of the button to something else, like:
<input id="mySubmitButton" name="mySubmitButton" value="Send to developer" type="submit" />
That’s all!
Now the explanation: the browser confuses your submit(); call with the button object, which has no such action.
The browser acted just like you were explicitly calling
button = document.getElementById( 'submit' ); button.submit();
[...] Form submit from JavaScript (tekkie.ro) [...]