
November 24th, 2011, 01:40 AM
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 2
Time spent in forums: 38 m 26 sec
Reputation Power: 0
|
|
|
Trouble passing variables to a popup window
Hi guys! So I have a little bit of a problem here. I am using PHP to write out a few links onto my webpage for users to redirect to, based on the data that it pulls from my database. These links open in popup windows. The problem I am experiencing is that the variables that are passed to the popup window are the same for each link, which should not happen. I am passing information to the javascript script via GET variables that are first defined in php. However, regardless of which link the user presses, the variables are always identical. This is a problem, because each link should display a separate image in the popup window. Here is my code:
The javascript "script":
Code:
<script language="javascript" type="text/javascript"> <!-- function popitup(url) {
newwindow=window.open('http://www.vgiver.com/viewgift.php?useraccess=<?php echo $userID; ?>&imagelink=<?php echo $linktopicture; ?>&friendname=<?php echo $nameoffriend; ?>&isprivate=<?php echo $isitprivate; ?>&canaccess=<?php echo $idoffriend; ?>&youraccessid=<?php echo $whosaccessid; ?>&countid=<?php echo $count; ?>','View the gift!','height=500,width=500');
if(!newwindow){ alert('We have detected that you are using popup blocking software...');} if (window.focus) {newwindow.focus()} return false; } // --> </script>
And now, the PHP code that defines it all:
Code:
for ( $count = 0; $count < sizeof($new_rows_data['picture']); $count++ )
{
if ($new_rows_Private['private'][$count] == 0 || $userid == $new_rows_ID['FriendID'][$count] || $access == $new_rows_AccessID['AccessID1'][$count]) {
$linktopicture = $new_rows_data['picture'][$count];
$nameoffriend = $new_rows_Name['name'][$count];
$isitprivate = $new_rows_Private['private'][$count];
$idoffriend = $new_rows_ID['FriendID'][$count];
$whosaccessid = $new_rows_AccessID['AccessID1'][$count];
$urldirection = "http://www.vgiver.com/viewgift.php?useraccess=".$userID."&imagelink=".$linktopicture."&friendname=".$nameoffriend."&isprivate=".$isitprivate."&canaccess=".$idoffriend."&youraccessid=".$whosaccessid;
echo '<a href="#" title="'.$nameoffriend.'" onclick="return popitup()"> <img src="'.$new_rows_Wrap['wrap'][$count].'"> </a>';
Any help would be greatly appreciated, as this is a non-negotiable feature of my program's functionality.
|