我有一个php页面“formpage.php”,有一个这样的表格:
<div id='hiddenform' style='display:hidden'>
<form name="testform" action="formpage.php" method="post">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
</div>
此表单以jquery和简单模态(示例)显示:
$(".show_hide").click(function(){
$('#hiddenform').modal({overlayClose:true});
});
一切正常,用SimpleModal打开框并显示表单,但我无法提交表单,当我按下提交按钮时没有任何反应。我该怎么办?没有SimpleModal,表单和提交工作正常。
我想将表单(使用SimpleModal打开)提交到formpage.phhp(self),然后我在脚本中进一步使用已发布的变量。
谢谢你的帮助!
答案 0 :(得分:0)
这有用吗?如果它在您的js中执行了某些操作,则会阻止表单的默认行为(可能是simplemodal可能是其他内容):
$(".show_hide").click(function(){
$('#hiddenform').modal({
overlayClose:true,
onShow: function() {
$('.simplemodal-data input[type=submit]').click(function() {
$.post('the_url_where_you_want_to_send_your_data_to', $(this).closest('form').serialize(), function(data) { alert('we have a response and form has been sent!'); })
}
}
});
});