Uncaught TypeError:document.getElementById(...)。submit不是一个函数 [英] Uncaught TypeError: document.getElementById(...).submit is not a function
本文介绍了Uncaught TypeError:document.getElementById(...)。submit不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么下面的代码不工作?
< html>
< body>
< form id =myFormaction =http://example.commethod =POST>
< input type =textname =enginevalue =v2.5/>
< input type =textname =verifyvalue =2/>
< input type =textname =submitvalue =Save/>
< / form>
< script type =text / javascript>
document.getElementById(myForm)。submit();
< / script>
< / body>
< / html>
我收到以下错误:
Uncaught TypeError:document.getElementById(...)。submit不是函数
谢谢。
我想发送一个名为submit的POST参数通过表单,这怎么能自动完成?
解决方案
name = submit
:
< input type =textname =submitvalue = 保存/>
将名称改为submit以外的名称。
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?
解决方案
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".
这篇关于Uncaught TypeError:document.getElementById(...)。submit不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文