"Submit is not a function" error in JavaScript
Solution 1:
submit is not a function
means that you named your submit button or some other element submit
. Rename the button to btnSubmit
and your call will magically work.
When you name the button submit, you override the submit()
function on the form.
Solution 2:
<form action="product.php" method="post" name="frmProduct" id="frmProduct" enctype="multipart/form-data">
<input id="submit_value" type="button" name="submit_value" value="">
</form>
<script type="text/javascript">
document.getElementById("submit_value").onclick = submitAction;
function submitAction()
{
document.getElementById("frmProduct").submit();
return false;
}
</script>
EDIT: I accidentally swapped the id's around
Solution 3:
If you have no opportunity to change name="submit"
you can also submit form this way:
function submitForm(form) {
const submitFormFunction = Object.getPrototypeOf(form).submit;
submitFormFunction.call(form);
}