masgas Posted September 28, 2006 Share Posted September 28, 2006 Hi! I want to pass the value of a mysql/php variable to a JavaScript pop up. The idea is, I show some information to the user, and if he wants to know more details, he can click on a link and open a popup where the info from the rest of the query I have in $result appears to him.The popup function in the head area is:function myPopup(){testpopup=window.open("popit.php","popit","status=0,height=200, width=400, menubar=0, resizable=0");testpopup.moveTo(200,100);}And in the body area the code is this:do { echo "<tr><td border='1' align='center' ><form><a href='javascript:myPopup ()'><b>".$row["lexx"]."</b><input type='hidden' name='".$row["email"]."' value=".$row["email"]."</form></a></td></tr>"; } while ($row = mysql_fetch_array($result));The popit.php has a simple table like this:<body><table width="100%" border="0" cellpadding="0"> <tr> <td>Nombre</td> <td>Apellido</td> <td>email</td> <td>Aeropuerto</td> </tr> <tr> <td><?php echo $Name; ?></td> <td><?php echo $Surname; ?></td> <td><?php echo $email; ?></td> <td><?php echo $lexx; ?></td> </tr> <tr> <td colspan="4"> </td> </tr></table>The result I get is an empty popup! Any ideas what is wrong? Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/ Share on other sites More sharing options...
alpine Posted September 28, 2006 Share Posted September 28, 2006 Most conveniant way is to pass variables as GET, then you must adjust the javasript:function myPopup(page){testpopup=window.open(page,"popit","status=0,height=200, width=400, menubar=0, resizable=0");testpopup.moveTo(200,100);}onclick="javascript: myPopup('popit.php?var=$var&morevar=$var2');" Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100380 Share on other sites More sharing options...
masgas Posted September 28, 2006 Author Share Posted September 28, 2006 thank you!I made the changes you said!the code looks like this now:echo "<tr><td border='1' align='center'><onclick='javascript: myPopup('popit.php?email=".$row["email"]."');><b>".$row["lexx"]."</b></a></td></tr>";I don't get the popup! and no link either... ??? Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100390 Share on other sites More sharing options...
alpine Posted September 28, 2006 Share Posted September 28, 2006 You where messing up with only single quotes around javascript, thats braking.This:[code]echo "<tr><td border='1' align='center'><a onclick=\"javascript: myPopup('popit.php?email=".$row["email"]."');\">".$row["lexx"]."</a></td></tr>";[/code] Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100401 Share on other sites More sharing options...
masgas Posted September 28, 2006 Author Share Posted September 28, 2006 thanks, link appears but no luck with pop up! :-\ Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100428 Share on other sites More sharing options...
alpine Posted September 28, 2006 Share Posted September 28, 2006 do you have a link to it for us to see ? Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100433 Share on other sites More sharing options...
masgas Posted September 28, 2006 Author Share Posted September 28, 2006 I'm working in local... Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100436 Share on other sites More sharing options...
masgas Posted September 28, 2006 Author Share Posted September 28, 2006 is the function declared correctly?function myPopup("popit.php"){testpopup=window.open("popit.php","popit.php","status=0,height=200, width=400, menubar=0, resizable=0");testpopup.moveTo(200,100);} Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100439 Share on other sites More sharing options...
alpine Posted September 28, 2006 Share Posted September 28, 2006 No - you are setting a permanent page.php inside it....This works (undo the spaces in S C R I P T due to forum issue):[code]<s c r i p t language="javascript">function myPopup(page){testpopup=window.open(page,"CtrlWindow","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=400,height=200");testpopup.moveTo(200,100);}</ s c r i p t><html><body><?php$email = $row["email"];$lexx = $row["lexx"];echo <<<_HTML<table><tr><td border='1' align='center'><a onclick="javascript: myPopup('popit.php?email=$email');">$lexx</a></td></tr></table>_HTML;?></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/22399-pass-php-variable-to-popup/#findComment-100452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.