View Full Version : passing a php variable to a javascript modal popout window

03-04-2012, 06:37 AM
On my main page, I have a list of item ID's which are assigned variables, the list is concatenated and so the variables are always different.

So another thing that gets concatenated is a link, which uses javascript/jquery to open a popout modal window which is another php file called sharepost.php. I want to be able to transfer the php variables from the main page to append them on the end of the sharepost.php URL so I can use $_GET to grab them for use.

Here's what I have... not working, but I figured I'd give it a try.


//use mysql to loop through some variables
$post_id = $setvalue;
$member_id = $anothersetvalue;

$list .= '

' . $post_id . '

' . $member_id . '

<a href="#" class="button" onClick="openup(); return false">Share This Post</a>

$the_link = " http://sharepost.php?post_id=' . $post_id . '&member_id=' . $member_id . ' ";



// Displays an external page using an iframe
function openup(){
var src = "<?php echo $the_link;?>";
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {

<?php echo $list;?>

03-04-2012, 08:47 AM
Everything is working fine EXCEPT- the variables ($post_id and $member_id) in the generated URL, are only getting the LAST value of the mysql query....

Even though the echoed variables in the $list, are getting the correct concatenated values.

03-04-2012, 09:34 AM
MySQL query? There is no such query. Loop? There is no loop ... please post the full/relevant code