【问题标题】:IE issue with input type submit输入类型提交的 IE 问题
【发布时间】:2014-12-02 18:36:03
【问题描述】:

提交表单后,在 $_POST 数组中未获得输入类型为 submitname

<input type="submit" name="approve" id="approve" value="Approve" class="btnSty" onclick="fnHideTextArea(); return fnRa1Validation();" >

(在fnRa1Validation() 表单中被提交并且控制转到另一个页面, 我确实在提交之前提醒了approve id 的值并获得了正确的值。)

提交后,我打印$_POST,在IE10/9中找不到approve

在 firefox 和 chrome 上运行良好。

这里是函数。

fnRa1Validation()
{
   // Some basic validations goes here...

   document.getElementById("page_action").value="Ra1Request";

   document.frmPost.action='manage_travel_expense_request.php';

   //alert(document.getElementById("approve").name);

  document.frmPost.submit();

}

需要帮助。

【问题讨论】:

  • 发布你的函数 fnRa1Validation()
  • 您是否尝试过将 JavaScript 代码移动到表单标签中? &lt;form onsubmit="..."&gt;
  • @Ja͢ck 是的。不工作,但是。
  • @Ja͢ck 无法将代码移动到&lt;form onsubmit="..."&gt; 并将其从当前onclick 中删除。表格太大了。
  • 在fnRa1Validation函数中尝试返回true

标签: javascript php html internet-explorer


【解决方案1】:
      <html>

      <form name="contactform" method="post" action="check.php" class="form-horizontal" role="form">
                   <input type="submit" name="approve" id="approve" value="Approve"       class="btnSty" onclick="fnHideTextArea(); return fnRa1Validation();" >

                   </form>

       <script>
         function fnHideTextArea()
         {
          alert("welcome");
         }
       </script>            

这在 IE 中有效。试试这个

【讨论】:

    【解决方案2】:

    Internet Explorer 不适用于 submit,除非正在提交的表单已添加到 DOM。

    所以,你需要添加一个技巧。

    将包装器 div post-form 添加到表单,然后单击该 div,触发表单的 submit 事件。

    $(".post-form").click(function(e) {
    

    【讨论】:

      猜你喜欢
      • 2010-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 2013-10-10
      相关资源
      最近更新 更多