【问题标题】:Redirect on Google after Successfully Submit Form成功提交表单后在 Google 上重定向
【发布时间】:2016-03-11 08:00:05
【问题描述】:

我创建了一个包含姓名、电子邮件、电话字段的表单。

<div class="col-md-4 col-md-offset-4 my">
 <form  role="form">
      <div class="form-group">
        <label for="contact_name">Name</label>
        <input class="form-control" id="contact_name" name="contact_name" required="true" type="text"/>
      </div>
      <div class="form-group">
        <label for="email_from">Email address</label>
        <input class="form-control" id="email_from" name="email_from" type="email"/>
      </div>
      <div class="form-group">
        <label for="phone">Phone No</label>
        <input class="form-control" id="pnone" name="phone" type="text"/>
      </div>
      <button class="btn btn-primary center-block" style="width: 35%;" type="submit">Submit</button>
    </form>
  </div

我想要操作和 onsubmit 事件。 操作是在哪里提交我的表单并在成功提交后提交重定向。 成功提交后,我想重定向到谷歌。

【问题讨论】:

  • “在谷歌上重定向”?详细解释。
  • 用代码更新问题,你这样做是为了什么..
  • 您是在点击提交后重定向,还是在保存数据后重定向?请详细说明

标签: javascript html forms


【解决方案1】:
   ....   
   document.formNameGoesHere.submit();
   window.location = "http://www.google.com";
});

【讨论】:

  • 你需要解释它是如何工作的以及放在哪里;该问题已标记为 JS,但作者可能不知道如何处理它。此外,我不确定这是否有效,因为 submit() 操作可能会在更改位置之前重定向到另一个页面。
【解决方案2】:

试试这个

$(document).ready(function(){
    $(".btn").click(function(){
        $(this).closest('form').submit();
        window.location="www.google.com";
    })
})

【讨论】:

    猜你喜欢
    • 2017-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-29
    • 1970-01-01
    • 1970-01-01
    • 2012-03-19
    相关资源
    最近更新 更多