我有一个窗体来显示网格数据(index.php)和自定义模态窗体(frmbts.php)来编辑网格中的数据。我不知道如何提交/张贴模态表单中的数据,然后在提交后关闭模态表单,如jqgrid的表单添加/编辑。如果我将提交按钮放入frmbts.php中,我可以提交数据。但是我不想实现(提交后无法关闭模式表单)。如何模仿提交按钮从自定义模式形式
这里是网格的代码(的index.php)
jQuery(document).ready(function(){ ...
jQuery("#list").jqGrid('navGrid','#page',{edit:true,add:true,del:true,search:true,refresh:true,position:'right',
editfunc: function(id){
jQuery('#frmbts').load('frmbts.php?id='+id);
jQuery('#frmbts').dialog({width:670,height:550,modal:true,title:'Edit Data',
buttons: { "Cancel": function() {
jQuery(this).dialog("close");
}, "Save": function() { <-- i want use this to submit data
//code to submit the form then close the form
jQuery(this).dialog("close");
} },
});
}}, ...
<div id="content">
<form id="frm" method="post" action="csvExport.php">
<div id="frmbts"></div>
<table id="list"></table>
<div id="page"></div>
<input id="csvBuffer" name="csvBuffer" type="hidden" value="">
<input id="typeinfo" name="typeinfo" type="hidden" value="">
</form>
</div>
模式窗体代码(frmbts.php)
<?php
$id = $_REQUEST['id'];
if(isset($_POST['submit']))
{
//update data
}
?>
<form name="frmsubmit" method="post" action="frmbts.php">
<table>...</table>
<input type="button" name="cancel" value="cancel">
<input type="submit" name="save" id="save" value="Save"> <--- just test. not the way i want
</form>
嗨Sergi拉蒙,谢谢。这行得通。但在提交模态表单后不要关闭。即使页面重定向到frmbts.php。提交后如何关闭模式表单而不重定向到frmbts?我已经把jQuery(this).dialog(“close”),但它不工作。 – satria
这是一个完全不同的解决方案,你需要为此使用ajax,我会改变答案。 –
对不起,我感到困惑。实际上我想说的是模式表单在提交后关闭,但index.php重定向到frmbts.php,我不想。 – satria