...

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



Juniper747
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.


<?php

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


$list .= '

<div>
' . $post_id . '
</div>

<div>
' . $member_id . '
</div>

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

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

';

?>

<HTML>
<head>
<script>
// 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">', {
closeHTML:"",
containerCss:{
height:150,
padding:0,
width:350
},
overlayClose:true,
});
}
</script>
</head>
<body>

<?php echo $list;?>
</body>
</HTML>

Juniper747
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.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum