Home > Backend Development > PHP Tutorial > 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
Release: 2023-04-09 13:54:02
forward
3285 people have browsed it

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'
});
Copy after login

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
 });
}
Copy after login

(2) Edit the main code of the page

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

(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);
		}
	}
Copy after login
	/**
	 * 关闭layer层
	 */
	public function closewindow(){
		$template = "close_layer";
		include $this->admin_tpl($template);
	}
Copy after login

(4) Close the window and refresh the key code of the parent window page

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

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!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template