Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 22nd, 2005, 10:36 AM
flyingchair flyingchair is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hong Kong
Posts: 108 flyingchair User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
maintaining state in JavaScript

Hello all.

I have a very simple little show/hide script.

The script is:

php Code:
Original - php Code
  1.  
  2.  
  3. function displayBoxes(currentMenu)
  4. {
  5.     var thisMenu = document.getElementById(currentMenu).style;
  6.    
  7.     if (thisMenu.display == "block")
  8.     {
  9.         thisMenu.display = "none";
  10.     }
  11.     else
  12.     {
  13.         thisMenu.display = "block";
  14.     }
  15.  
  16.    
  17.     return false;
  18.    
  19. }
  20.  


(you have all seen that one before)

and this is an example of what it is hiding:


php Code:
Original - php Code
  1.  
  2. <h3 onClick="return displayBoxes('scratchPad')">Scratchpad</h3>
  3.        
  4. <div style="display:none;" id="scratchPad">
  5.        
  6. <iframe src="scratchpad.php" width="196" align="middle" height="200" marginheight="0" marginwidth="0">
  7. </iframe>
  8.        
  9. </div>
  10.  


The reaons for the iframe is that it contains a form and I cannot repost the whole page - there is a lot going on.

I want to maintain state but while I write cookies in PHP with my eyes closed I can't quite get JavaScript to do what I want to even though it should be easy. What changes do I need to make to the above so that the block/none value of each included element's style.display value (there are more than one) is maintained after reloading the container page?

Reply With Quote
  #2  
Old February 22nd, 2005, 05:37 PM
Yian Yian is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: UK
Posts: 279 Yian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: maintaining state in JavaScript

Well I suppose you could just send it in $_SESSION or another global, then write the html with PHP not separately:
echo "<div style="display:".$_SESSION['display'].";" id="scratchPad">";

Reply With Quote
  #3  
Old February 22nd, 2005, 05:40 PM
flyingchair flyingchair is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hong Kong
Posts: 108 flyingchair User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: maintaining state in JavaScript

No, because every time I invoke the function I have to write the value from the JavaScript. I tried reading it with PHP when the page loads but it just did not work and I could not fathom out why. I was wondering if someone could help me cheat and give me an all JavaScript option...

Reply With Quote
  #4  
Old February 23rd, 2005, 06:49 PM
Yian Yian is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: UK
Posts: 279 Yian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: maintaining state in JavaScript

Well you could use cookies through Javascript.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > maintaining state in JavaScript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway