“提交不是功能” JavaScript中的错误 [英] "Submit is not a function" error in JavaScript

查看:91
本文介绍了“提交不是功能” JavaScript中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我这个代码出了什么问题?我试图用JavaScript提交表单,但是显示的错误.submit不是一个函数。有关代码的更多详细信息,请参阅以下内容:

 < form action =product.phpmethod =getname = frmProductid =frmProductenctype =multipart / form-data> 

< input onclick =submitAction()id =submit_valuetype =buttonname =submit_valuevalue =>

< / form>

< script type =text / javascript>
function submitAction()
{
document.frmProduct.submit();
}
< / script>

我也尝试过:

 < script type =text / javascript> 
function submitAction()
{
document.forms [frmProduct]。submit();
}
< / script>

两者都显示相同的错误:(

解决方案


提交不是一个功能


意味着你命名你的提交按钮或其他元素提交。将按钮重命名为 btnSubmit ,你的电话将会神奇地工作。 p>

当您命名按钮提交时,您将覆盖表单上的 submit()函数。


Can anyone tell me what is going wrong with this code? I tried to submit a form with JavaScript, but an error ".submit is not a function" shown. See below for more details of the code:

<form action="product.php" method="get" name="frmProduct" id="frmProduct" enctype="multipart/form-data">

<input onclick="submitAction()" id="submit_value" type="button" name="submit_value" value="">

</form>

<script type="text/javascript">
    function submitAction()
    {
        document.frmProduct.submit();
    }
</script>

I also tried this:

<script type="text/javascript">
    function submitAction()
    {
        document.forms["frmProduct"].submit();
    }
</script>

Both show me the same error :(

解决方案

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.

这篇关于“提交不是功能” JavaScript中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆