Jump to content

[SOLVED] Php inside JS script?


Nexy

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.