bioshock Posted December 5, 2010 Share Posted December 5, 2010 Hi people! I have this code: if ($_POST['remember'] == true) { // COOKIES ON! $time = time() + 20000; setcookie(user, $username, $time); setcookie(pass, $password, $time); header("Location: index.php"); echo "<h1 class='welcome'>Welcome ".$_COOKIE['user']." |</h1>"; echo "<div id='divlogin' style='visibility:hidden'></div>"; echo "<a href='logout.php'><h1 class='logout'><b>Logout</b></h1></a>"; }elseif ($_POST['remember'] == false){ echo "<div id='divlogin' style='visibility:hidden'></div>"; echo "Div hidden!"; } "remember" - is a checkbox. So, if the checkbox is checked then I will activate the cookies and hide the divlogin (till now everything is fine), but if the checkbox isn't checked, I will just hide the divlogin (and this don't happen), however, the echo "Div hidden!" works nicely. The code detects if the checkbox is checked or not, the only problem is that if isn't checked the div doens't hide. Any ideas? :-\ Thanks Quote Link to comment https://forums.phpfreaks.com/topic/220767-hiding-div/ Share on other sites More sharing options...
jcbones Posted December 6, 2010 Share Posted December 6, 2010 The correct CSS to hide an element is "display:none;" Quote Link to comment https://forums.phpfreaks.com/topic/220767-hiding-div/#findComment-1143435 Share on other sites More sharing options...
bioshock Posted December 6, 2010 Author Share Posted December 6, 2010 Hi! I'd already tried that and is the same thing. if ($_POST['remember'] == true) { // COOKIES ON! $tempo = time() + 20000; setcookie(user, $username, $tempo); setcookie(pass, $password, $tempo); header("Location: index.php"); echo "<h1 class='welcome'>Bem vindo ".$_COOKIE['user']." |</h1>"; echo "<div id='divlogin' class='divlogin' style='display:none'></div>"; echo "<a href='logout.php'><h1 class='logout'><b>Logout</b></h1></a>"; // OFF }elseif ($_POST['remember'] == false){ // Dispomos as divs, etc, como desejo. echo "<div id='divlogin' class='divlogin' style='display:none'></div>"; echo "<a href='logout.php'><h1 class='logout'><b>Logout</b></h1></a>"; } Can't you give me an example with a checkbox and hiding divs? Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/220767-hiding-div/#findComment-1143582 Share on other sites More sharing options...
jcbones Posted December 9, 2010 Share Posted December 9, 2010 There is nothing inside of your div that you are hiding. So it will not show either way, as you cannot see an empty div (unless it has a border). Quote Link to comment https://forums.phpfreaks.com/topic/220767-hiding-div/#findComment-1145153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.