lunny Posted May 1, 2007 Share Posted May 1, 2007 First off I would like to create a pop-up, and with this send 2 variables which are needed for the functions in the pop-up. I dont want to use session since I want for example 6 different links on a page to the pop-up each time displaying different information in the pop-up based on the variables passed. Also I started with just creating pop-ups : function OpenWindow(URL) { var MyPopupWindow = window.open(URL); } and <a href="javascript:OpenWindow('http://x');">Using a Custom Javascript Function</a> But keep getting object expected error Link to comment https://forums.phpfreaks.com/topic/49423-send-variables-with-pop-up/ Share on other sites More sharing options...
jitesh Posted May 1, 2007 Share Posted May 1, 2007 function OpenWindow(URL) { var MyPopupWindow = window.open(URL); } and <a href="javascript:OpenWindow('http://x?name=john&no=1');"> Link to comment https://forums.phpfreaks.com/topic/49423-send-variables-with-pop-up/#findComment-242188 Share on other sites More sharing options...
lunny Posted May 1, 2007 Author Share Posted May 1, 2007 Ah cool and then how do I read these values? Link to comment https://forums.phpfreaks.com/topic/49423-send-variables-with-pop-up/#findComment-242191 Share on other sites More sharing options...
jitesh Posted May 1, 2007 Share Posted May 1, 2007 $_GET OR $_REQUEST Link to comment https://forums.phpfreaks.com/topic/49423-send-variables-with-pop-up/#findComment-242200 Share on other sites More sharing options...
lunny Posted May 1, 2007 Author Share Posted May 1, 2007 Ok next problem.. On this pop-up I was able to read in the variables from the URL np, thanks a lot for that. The problem is i want to use these variables in the Onload method which is set in body. So I tried <body onload="load(<?php $_GET['long'];?>, <?php $_GET['late'];?>)" > But isnt working as when I just put the numbers in, any ideas ? Link to comment https://forums.phpfreaks.com/topic/49423-send-variables-with-pop-up/#findComment-242221 Share on other sites More sharing options...
woody79 Posted May 1, 2007 Share Posted May 1, 2007 Just in case you want to use this: Main Page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Test</title> <script type="text/javascript"> function myPopup(url, width, height) { window.open(url, 'MyPopUp', width, height); } </script> </head> <body> <form target="MyPopUp" action="popup.php" name="myForm"> <input type="text" name="myText" /><br /> <input type="submit" value="Submit" name="process" onclick="myPopup('popup.php', '400', '400');" /> </form> </body> </html> popup.php : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Pop-Up</title> <?php $myText = $_REQUEST['myText']; $process = $_REQUEST['process']; if($myText == "" || !isset($myText)) { $close = 1; }else{ $myString = $myText . "<br />\r\n"; } ?> </head> <body <?php if($close == 1) { print " onload=\"self.close();\""; } ?>> <?php echo $myString; ?> </body> </html> Woody Link to comment https://forums.phpfreaks.com/topic/49423-send-variables-with-pop-up/#findComment-242223 Share on other sites More sharing options...
lunny Posted May 1, 2007 Author Share Posted May 1, 2007 Thanks a lot got it all working, nice work Link to comment https://forums.phpfreaks.com/topic/49423-send-variables-with-pop-up/#findComment-242271 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.