我想在表单按钮中使用模式框,如上所示。但是当我点击按钮时,会出现一个模态框而不是重定向到action="email/index.php"
。如何重定向到action="email/index.php"
并同时使用data-toggle
?
这是我的代码:
<form name="enq" method="post" action="email/index.php" onsubmit="return validation();">
<fieldset>
<input type="text" name="name" id="name" value=""
class="input-block-level" placeholder="Name" />
<br /><br />
<input type="text" name="email" id="email" value=""
class="input-block-level" placeholder="Email" />
<br /><br />
<textarea rows="11" name="message" id="message"
class="input-block-level" placeholder="Comments"></textarea>
<br /><br />
<div class="actions">
<input type="submit" value="Send Your Message" name="submit" id="submitButton"
class="btn btn-info pull-right" data-toggle="modal" data-target="#myModal"
title="Click here to submit your message!" />
</div>
</fieldset>
</form>
答案 0 :(得分:0)
我建议你使用ajax技术,用这个你可以去服务器 捕获数据,从而打开你的模态
$('form#enq').on('submit',function(event){
event.preventDefault();// prevents the default redirections
// store reference to the form
var bk_this = $(this);
// grab the url from the form element
var url = bk_this.attr('action');//it contains your url: email/index.php
//Obteniendo la data del form
var dataToSend = bk_this.serialize();
var fo_proccess = function (data){
// here you can open your model box manually
$('#myModal').modal('show');
}
$.post( url, dataToSend, fo_proccess,'json');
});