Computer Programming web Web programming Tips



How to Pass Array Parameters to a Modeless Popup

By Sergey Skudaev

Happy Amazon Prime Day July 12 - Exclusive Deals for Prime Members - Start Free 30-Day Trial

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>

Subscribe to our mail list to receive free code examples.

Comments

No comments yet.

Add Comment

* Required information
(never displayed)
 
Smile Sad Huh Laugh Mad Tongue Crying Grin Wink Scared Cool Sleep Blush Unsure Shocked
 
1000
What is the sum of 1 + 2 + 3?
 
Enter answer:
Captcha
Refresh
 
Enter code:
 
Notify me of new comments via email.
 
Remember my form inputs on this computer.
 
I have read and understand the privacy policy. *
 
I have read and agree to the terms and conditions. *
 
 
Powered by Commentics

My eBooks on Amazon.com

Learn C++ Programming By Examples

Learn SQL Programming By Examples

Learn PHP Programming by Examples

Visual Basic Programming By Examples

How to Build Your Own Web Site from Scratch