2016-03-11 43 views
-4

我创建了一个名称,电子邮件,电话字段的表单。成功提交表单后在Google上重定向

<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事件。 行动是提交我的表单和onsubmit成功submited后重定向的地方。 成功提交后,我想重定向到Google。

+0

“对谷歌重定向”?详细解释。 –

+0

用代码更新问题,你这样做了什么.. – shas

+0

你是否在clik提交或保存数据后重定向?请详细解释 –

回答

0
.... 
    document.formNameGoesHere.submit(); 
    window.location = "http://www.google.com"; 
}); 
+0

你需要解释它是如何工作的以及在哪里放置它;该问题被标记为JS,但作者可能不知道如何处理它。另外,我不确定这会起作用,因为'submit()'操作可能会在更改位置之前重定向到另一个页面。 –

0

试试这个

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