Results 1 to 2 of 2

Thread: box open/close keeping state

  1. #1
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default box open/close keeping state

    Hello

    I am using that code


    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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You'd want to store a cookie and check that value when the page is loaded.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •