php 提交表单 关闭layer弹窗iframe的实例讲解

发布时间:2022-04-16 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了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的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本宝典。

脚本宝典总结

以上是脚本宝典为你收集整理的php 提交表单 关闭layer弹窗iframe的实例讲解全部内容,希望文章能够帮你解决php 提交表单 关闭layer弹窗iframe的实例讲解所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:layerphp