php 提交表单 关闭layer弹窗iframe的实例讲解
更新时间:2018年08月20日 09:43:04 作者:不会飞的程序猿
今天小编就为大家分享一篇php 提交表单 关闭layer弹窗iframe的实例讲解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
介绍一款非常好用的前端弹窗插件:
layer 官网地址:http://layer.layui.com/
根据官方的API:layer的iframe弹窗
//iframe层-父子操作 layer.open({ type: 2, area: ['700px', '530px'], fix: false, //不固定 maxmin: true, content: 'test/iframe.html' });
这里以php开发为例 演示如何 提交表单后自动关闭layer弹窗
(1)弹出layer编辑框 :
function edit(id){ if(id==null||id==''||id=='undefined'){ alert('操作编号为空,请联系管理员'); } layer.open({ type: 2, area: ['700px', '530px'], fix: false, //不固定 maxmin: true, content: 'index.php?m=content&c=meiti&a=edit_paiqi&id='+id }); }
(2)编辑页面主要代码
<input name="dosubmit" type="submit" id="dosubmit" value="提交" class="button" >
(3)php后台保存数据并指向一个关闭layer窗口的方法
public function edit_config_paiqi(){ $id = trim($_REQUEST['id']); $paiqi_db = pc_base::load_model('paiqi_config_model'); if($_REQUEST['dosubmit']){ $insertinfo = array(); $insertinfo['catid'] = trim($_POST['catid']); $insertinfo['meitiid'] = trim($_POST['meitiid']); $insertinfo['title'] = trim($_POST['title']); $insertinfo['meitizhuname'] = trim($_POST['meitizhuname']); $insertinfo['meitizhuid'] = trim($_POST['meitizhuid']); $insertinfo['createtime'] = SYS_TIME; $insertinfo['saturation'] = trim($_POST['saturation']); $datas = $paiqi_db->update($insertinfo,array("id"=>$id)); if($datas){ <span style="color:#ff0000;">showmessage(L('operation_success'),'?m=content&c=meiti&a=closewindow');//保存成功指向关闭窗口方法</span> } }else{ $datas = $paiqi_db->select(array("id"=>$id)); $template = "edit_config_paiqi"; include $this->admin_tpl($template); } }
/** * 关闭layer层 */ public function closewindow(){ $template = "close_layer"; include $this->admin_tpl($template); }
(4)关闭窗口并刷新父窗口页面的关键代码
$(function(){ parent.location.reload();//刷新父窗口 parent.layer.closeAll();//关闭所有layer窗口 });
注意:该页面需要加载layer需要的js库才能使用layer方法
以上这篇php 提交表单 关闭layer弹窗iframe的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
vscode运行php报错php not found解决办法
这篇文章主要给大家介绍了关于vscode运行php报错php not found的解决办法,这个问题可能是由于您的计算机上没有安装PHP或者VS Code没有正确配置PHP的路径所导致的,文中将解决的办法介绍的很详细,需要的朋友可以参考下2023-07-07Ajax PHP JavaScript MySQL实现简易无刷新在线聊天室
这篇文章主要为大家详细介绍了Ajax PHP JavaScript MySQL实现简易无刷新在线聊天室,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2016-08-08
最新评论