Issue Displaying Div (javascript and php)
Posted: Mon Oct 12, 2009 10:20 am
here's the basic structure in sudo code
Code: Select all
<script type='text/javascript'>
if (box is hidden)
show box
update cookie to say box is now visible
else
hide box
update cookie to say box is now hidden
</script>
<body>
<?php
if(cookie for box)
display box
?>
</body>
the cookie is a boolean value. the problem is that when i click a link to show the box, the box does not display because even though i update the cookie to say 'show the box', the php code below has already executed and read to hide the box (if i refresh the page the box will show because the php code reads the updated cookie value).
I understand why it's happening, but can't figure out a solution to combat this. any ideas?