Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: document.getElementById(...).submit is not a function

Why doesn't the following code work?

<html>
<body>
<form id="myForm" action="http://example.com" method="POST">
<input type="text" name="engine" value="v2.5" />
<input type="text" name="verify" value="2" />
<input type="text" name="submit" value="Save" />
</form>
<script type="text/javascript">
document.getElementById("myForm").submit();
</script>
</body>
</html>

I'm getting the following error:

Uncaught TypeError: document.getElementById(...).submit is not a function

Thanks.

I want to send a POST parameter named submit through forms, how can this be done automatically?

like image 814
John Doe Avatar asked Mar 24 '26 03:03

John Doe


1 Answers

myForm.submit is a reference to the text input with name="submit":

<input type="text" name="submit" value="Save" />

Change the name to something other than "submit".

like image 164
Nathan Piercy Avatar answered Mar 25 '26 16:03

Nathan Piercy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!