Passing a variable via href

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Passing a variable via href

Post by amir »

I need to have a series of links that call a dynamic div pop section (overlay) in my php page.

The current link is:

Code: Select all

<a href="javascript:;" id='Message' onClick="document.getElementById('content').style.display = 'none';document.getElementById('overlay').style.visibility='visible';return false;" style="cursor:hand" onmouseover="window.status='';return true;" onmouseout="window.status=' ';return true;">Click Here</a>
Can I set a _Session variable and retrieve it in the div pop? If not, how can this be done?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You can write the session variable's value so that it appears in the javascript code. But (client-side) javascript cannot access (server-side) php's variables directly.
e.g.

Code: Select all

<?php /* some php code */ ?>
<a href="javascript:;" id='Message' onClick="document.getElementById('content').style.display = 'none';document.getElementById('<?php echo $_SESSION['yadda'];?>').style.visibility='visible';return false;" style="cursor:hand" onmouseover="window.status='';return true;" onmouseout="window.status=' ';return true;">Click Here</a>
Post Reply