Home  >  Article  >  Backend Development  >  Example to explain how to close layer pop-up iframe in php submission form

Example to explain how to close layer pop-up iframe in php submission form

coldplay.xixi
coldplay.xixiforward
2020-08-14 17:15:073249browse

Example to explain how to close layer pop-up iframe in php submission form

##Introducing a very easy-to-use front-end pop-up plug-in:

layer official website address: http://layer.layui.com/

According to the official API: layer’s iframe pop-up window

//iframe层-父子操作
layer.open({ 
 type: 2, 
 area: ['700px', '530px'], 
 fix: false, //不固定 
 maxmin: true, 
 content: 'test/iframe.html'
});

Here uses PHP development as an example to demonstrate how to submit Automatically close the layer pop-up window after the form

(1) Pop up the layer editing box:

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) Edit the main code of the page

<input name="dosubmit" type="submit" id="dosubmit" value="提交" class="button" >

(3) PHP saves data in the background and points to a method to close the layer window

public function edit_config_paiqi(){
		$id = trim($_REQUEST[&#39;id&#39;]);
		$paiqi_db = pc_base::load_model(&#39;paiqi_config_model&#39;);
		if($_REQUEST[&#39;dosubmit&#39;]){
			$insertinfo = array();
			$insertinfo[&#39;catid&#39;] = trim($_POST[&#39;catid&#39;]);
			$insertinfo[&#39;meitiid&#39;] = trim($_POST[&#39;meitiid&#39;]);
			$insertinfo[&#39;title&#39;] = trim($_POST[&#39;title&#39;]);	
			$insertinfo[&#39;meitizhuname&#39;] = trim($_POST[&#39;meitizhuname&#39;]);
			$insertinfo[&#39;meitizhuid&#39;] = trim($_POST[&#39;meitizhuid&#39;]);
			$insertinfo[&#39;createtime&#39;] = SYS_TIME;
			$insertinfo[&#39;saturation&#39;] = trim($_POST[&#39;saturation&#39;]);
			$datas = $paiqi_db->update($insertinfo,array("id"=>$id));
			if($datas){
				<span style="color:#ff0000;">showmessage(L(&#39;operation_success&#39;),&#39;?m=content&c=meiti&a=closewindow&#39;);//保存成功指向关闭窗口方法</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) Close the window and refresh the key code of the parent window page

$(function(){
 parent.location.reload();//刷新父窗口 
 parent.layer.closeAll();//关闭所有layer窗口
});

Note: This page needs to load the js library required by the layer to use the layer method

Related learning recommendations:

phpprogramming(video)

The above is the detailed content of Example to explain how to close layer pop-up iframe in php submission form. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete