Page 1 of 1

Passing a variable via href

Posted: Thu Nov 30, 2006 1:55 pm
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?

Posted: Thu Nov 30, 2006 3:08 pm
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>