PDA

View Full Version : box open/close keeping state



anselemej
07-21-2007, 06:59 AM
Hello

I am using that code





function shDiv(popup)
{

var box = document.getElementById(popup)
var a = document.getElementById(popup + '_a')
var t = document.getElementById(popup + '_t')


a.innerHTML =(a.innerHTML=='[ - ]')?'[ + ]':'[ - ]';
t.className =(t.className=='Tclose')?'Topen':'Tclose';
box.style.display = (box.style.display=='none')?'block':'none';
}


<h4>
<a href="#" onclick="shDiv('box1');" id="box1_a">[ + ]</a>
<span id="box1_t" class="Topen">Box 1</span></h4>

<div class="shBox" id="box1" style="display:none;">Content 1</div>



it works fine but if a box is closed and the page is reloaded then the box open again, how is it possible to keep the box status : open if open , close if close ?

thank you

djr33
07-21-2007, 07:04 AM
You'd want to store a cookie and check that value when the page is loaded.