Nexy Posted June 27, 2008 Share Posted June 27, 2008 Why Hello There! Is there a way to do this: Shoutbox ( <a href="javascript:;" onmousedown="if(document.getElementById('shoutbox').style.display == 'none' || document.getElementById('shoutform').style.display == 'none') { document.getElementById('shoutbox').style.display = 'block'; document.getElementById('shoutform').style.display = 'block'; <?php $_SESSION['shout'] = "Show"; ?> } else { document.getElementById('shoutbox').style.display = 'none'; document.getElementById('shoutform').style.display = 'none'; <?php $_SESSION['shout'] = "Hide"; ?> } ">Show/Hide</a> ) <?php if($_SESSION['shout'] == "Hide") { echo "<div id='shoutbox' name='shoutbox' style='display:none'>"; } else if($_SESSION['shout'] == "Show") { echo "<div id='shoutbox' name='shoutbox' style='display:block'>"; } ?> What I'm trying to do is to save Show or Hide in the session, so if you go to another page on the site, it remembers the selection you made. If you chose Show, if would stay shown on each page you visit and vice versa. Right now, even if you visit a new page, the <div> hides every time unless you click the link. I do have "session_start();" on the top. Any help would be appreciated. Thank You! Link to comment https://forums.phpfreaks.com/topic/112129-solved-php-inside-js-script/ Share on other sites More sharing options...
kenrbnsn Posted June 27, 2008 Share Posted June 27, 2008 The only way to do that is via AJAX. Ken Link to comment https://forums.phpfreaks.com/topic/112129-solved-php-inside-js-script/#findComment-575661 Share on other sites More sharing options...
Nexy Posted June 27, 2008 Author Share Posted June 27, 2008 Oh, OK. I'll read up on how to do it with Ajax. Thank you! Link to comment https://forums.phpfreaks.com/topic/112129-solved-php-inside-js-script/#findComment-575662 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.