How to Pass $_GET Parameters to a Modeless Popup

+++++

I show you how to create a modeless popup and pass $_GET parameters from a parent page to the popup page. I use PHP and JavaScript to make it possible. JavaScript modelessparam function creates a modeless popup. Then in the URL you pass parameters and read them in popup page.

This is a script for main page:

parent.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head> <title>Pass params to modeless popup</TITLE>

<?php

$param1="Hello There!";
$param2="Hi World!";

?>
<script language="JavaScript" type="text/javascript">

function modelessparam(url,width,height){
if (document.all&&window.print) //if ie5
eval('window.showModelessDialog(url,"","help:0;resizable:1;dialogWidth:'+width+
'px;dialogHeight:'+height+'px")')
else
eval('window.open(url,"","width='+width+'px,height=
'+height+'px,resizable=1,scrollbars=1")')
}

</script>
</head>

<body>

<p align="center"><input type="button" name="greeting" value="Open Popup"
onClick="javascript:modelessparam(
'http://yourdomain/popup/popup.php?param1=<? echo $param1;
? >&param2=<? echo $param2; ?>',300,200)"></p>

</form>

</body>
</html>

This is a script for popup page:

popup.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Popup with param from parent window</title>
<?

if(isset($_GET['param1']))
$param1 =$_GET['param1'];

if(isset($_GET['param2']))
$param2 =$_GET['param2'];

?>

</head>
<body bgcolor="#996699">
<?php

print('<p style="align:center; font-size:40px; color: #000;">'. $param1.'</p>');

print('<p style="align:center; font-size:50px; color: #000;">'.$param2.'</p>');

?>
</body>
</html>

- =

Please rate the tutorial

1 2 3 4 5 6 7 8 9 10



Learn SQL Programming By Examples [Kindle Edition]2.99

Learn PHP Programming by Examples [Kindle Edition] $2.99

Learn Visual Basic 6.0 [Kindle Edition] $1.99

How to Build Your Own Web Site from Scratch [Kindle Edition] $1.49

New-trip.com website source code

Comments
 
Register to add comments ( 1000 char ) for modeless_popup.php.