Hidden DIV state?
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=19320
Printed Date: 28 March 2026 at 5:59pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Hidden DIV state?
Posted By: Mikey
Subject: Hidden DIV state?
Date Posted: 15 April 2006 at 3:52pm
I'm trying to impliment the use of DIV blocks in the left hand side bar of my currently in development website. The idea is to have these blocks so they can be toggled between hidden and shown. this bit i have already managed to do but now i need to find a way for them to remain in the users chosen state while they browse around the site. Presently they pop back to their default state with every page refresh or change.
I'm aware that i could have this on either a per session or a perminant cookie but have absoloutley no idea how to get this working.
So it falls to me to ask the wonderful members of Web Wiz ( arse kissing) the best way to do this or any ideas i should take into concideration?
Cheers in advance for any help offered.
http://www.skatenstone.co.uk/scumbag/forum/ - Demo page
If you wanna see what i'm talking about click the 'member control panel' or 'SNS Mailing List' links. 
------------- Handyman man?
|
Replies:
Posted By: pilot99
Date Posted: 21 April 2006 at 2:22am
you would have to do something like when you click hide the write a cookie that says hide it then have an if statement. if i could see the code youve already made i might be able to help u more.
------------- http://www.globaltornado.com">
|
Posted By: Mikey
Date Posted: 21 April 2006 at 3:53pm
Damn i knew it would come down to cookies, i suck at cookies 
Currently i have this code in a seperate 'tooglediv.js' file
function toggleLayer(whichLayer) { if (document.getElementById) { //Standardising var style2 = document.getElementById(whichLayer).style; style2.display = style2.display? "":"block"; } else if (document.all) { // Crappy IE version var style2 = document.all[whichLayer].style; style2.display = style2.display? "":"block"; } else if (document.layers) { // NN4 var style2 = document.layers[whichLayer].style; style2.display = style2.display? "":"block"; } }
|
And this is the code thats called in the page that the .js is included in
<div id="containerlayer"> <a href="javascript:toggleLayer('hideablelayer');"> Click to toggle layer </a> <div id="hideablelayer"> <!-- ### Content to show or hide is in here ### ---> </div> </div
|
and the CSS for the toggle'able layer is...
div#hideablelayer { margin: 0px 0px 0px 0px; display: none; }
|
------------- Handyman man?
|
Posted By: dpyers
Date Posted: 21 April 2006 at 7:18pm
If it's just needed for the life of the session, I'd use the session object server side - e.g. Session("page1_div1"} = "hidden" and use it to customize inline css for the page
-------------
Lead me not into temptation... I know the short cut, follow me.
|
Posted By: Mikey
Date Posted: 21 April 2006 at 8:55pm
Woah thats already exceeded my skill capacity 
Thanks for the suggestions, i'll go away and read up on them see what i can figure out
------------- Handyman man?
|
|