Auto submission of a form can be done by the line “document.forms[0].submit()” (if the page contains a single form) or “document.getElementById(“formId”).submit()”. But if any other element in the whole form named submit, it shows error “document.forms[0].submit() is not a function” in place of submitting the form. Suppose if one have a submit button with name=”submit” as the following code
<input onclick="submitForm();" name="submit" type="button" value="Submit" />
function submitForm() {
document.forms[0].submit();
}
This code shows the error. One can resolve the error by rewriting the button name anything else except “submit”
<input onclick="submitForm();" name="save" type="button" value="Submit" />
I am not so clear about this factor. Most probably, if any element named submit then the word submit assigned as that element in place of submit function. When you submit a form it got a button with the name submit not a function.
by: Md. Shahjalal
23.783439
90.393938