简体   繁体   English

提交不是js中的函数

[英]Submit is not a function in js

I have a struts 2 form tag,i am trying to submit the form using the java script function.But when i try to do this i am getting the following error. 我有一个struts 2表单标签,我试图使用java脚本函数提交表单。但是当我尝试这样做时,我收到以下错误。

"document.testForm.submit is not a function" IE 8(Object doesn't support this property or method)

Here is my java script function and html code:- 这是我的java脚本函数和html代码: -

<script type="text/javascript">
        function testFunction()
        {
          document.testForm.action = "testAction";
           document.testForm.submit();

        }
</script>

<s:form method="POST"  id="fileForm" name="testForm"
    enctype="multipart/form-data">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
       <tbody>
        <tr>
           <td>
             <input type="button" name="submit" value="Upload File"    onclick="testFunction();"/>
           </td>
            </tr>
       </tbody>
   </table>
</s:form>

I am using FF 7 and IE 8 我正在使用FF 7和IE 8

Please help me out. 请帮帮我。

The problem is that you've named your submit button "submit": 问题是您已将提交按钮命名为“提交”:

<input type="button" name="submit" ...>
<!--                 ^^^^^^^^^^^^^  -->

Change it to just about anything else. 将其更改为其他任何内容。 Form elements get added as properties to the form object using their names, so that shadows (overrides) the form's built-in submit property (which is the function you're looking for). 表单元素使用其名称作为属性添加到表单对象,以便阴影(覆盖)表单的内置submit属性(这是您正在寻找的功能)。

I think you need to change the name of your submit-button. 我想你需要更改提交按钮的名称。 Change it to name="Submit" or something else and try again. 将其更改为name="Submit"或其他内容,然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM