我的代码没有处理动作方法

0 javascript php

此代码用于前端和csv文件中的显示报告也会使此代码正常运行,并且此代码在同一页面上重定向document.frmmonthly.action ="test2.php"; 但是第二个代码没有正常工作,代码没有重定向到其他页面是什么原因或我的代码中的问题是什么...... document.frmmonthly.action ="csv.php";

动作方法不适用于csv.php .....我的代码不工作PLZ帮我...

<head> 
    <script language="text/javascript">
        function OnSubmitForm(value) {    
           if(value == 'Generate')  {
              document.frmmonthly.action ="test2.php";
           } else if(value == 'Download') {
              document.frmmonthly.action ="csv.php";
           }

           return true;
       }    
    </script>
    </head>
    <form method="POST" onSubmit="return OnSubmitForm();">
         </tr>
        <tr>
            <td><input type="submit" name="submit" 
                               onSubmit="OnSubmitForm(this.value)" 
                               value="Generate"></tr>
        <tr>
            <td><input type="submit" name="submit1" 
                               onSubmit="OnSubmitForm(this.value)" 
                               value="Download" action="csv.php">
        </tr>       
    </form>
Run Code Online (Sandbox Code Playgroud)

Tyr*_*ron 5

试试这个:

<form method="POST" name="frmmonthly" onSubmit="return OnSubmitForm();">
Run Code Online (Sandbox Code Playgroud)

[编辑:]你还必须重命名onSubmit,例如onClick

  • +1和小注:onsubmit应更改为仅在按钮上单击. (2认同)