?
Solved

Maintaining state

Posted on 2003-12-11
6
Medium Priority
?
414 Views
Last Modified: 2006-11-17
Hi, I have PHP and javascript. I have a nice DHTML page I made for a menu thingy, that has a number of links that can be shown/hidden.  When the user returns to the page it is reloaded from the server and rebuilt.  But I would like the users to be able to return to it in the state they left it.  The thingy has lots of hide/show sections. I guess I could get javascript to send a record of all the show states to the server as GET parameters, or maybe even POST an array of thingy states along when a link is selected - so the server could recreate it in the same state.  But what I was wondering is whether I can get javascript to keep and update the show states client-side between pages, somehow, and reload them?  Would a cookie allow this?
0
Comment
Question by:kaller2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 22

Accepted Solution

by:
pjedmond earned 252 total points
ID: 9923847
Yes - cookies are probably the way to go, BUT, some people disable cookies, so this process cannot be reliedon:(

He is a link on how to to set/reset/read cookies:

http://blazonry.com/javascript/cookies.php


HTH:)
0
 
LVL 25

Assisted Solution

by:James Rodgers
James Rodgers earned 248 total points
ID: 9923927
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9925665
If your using php, then i would forget the cookies all together
and set a var on the server some how when a menu is expanded and when it is closed.

or
just use either hidden form fields, and onload have an init function to read the hidden field value(s) and then show or hide the menu(s)  

or

You could pass a query string thru the link and use php to read the query str and set your menu up like that, or use location.search in javascript to read it.
0
 
LVL 2

Author Comment

by:kaller2
ID: 9928185
Yes I have heard these urban myths that some people turn off cookies, but I have yet to meet one of these mythical beings that programming folk legends thrive apon.  I imagine they eat their meat raw and light fire by rubbing sticks together.  Tales of latterday luddites?  Lump these with the half a dozen users world wide using Netscape 3 no doubt?  And thin client ?  It is not always a good idea to hammer the pipe to the server when you have a gazillion megaflops lying idle on the users desktop?  Idle that is apart from the mis-application of enormous computing power to the simple problem being an operating system, with a propensity to fail.  And generate endless pseudo support teaser messages - these must be the same half wits who press the "send" button ;)

Seriously tho many thanks for the cookie refs, reading now...
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10395690
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: pjedmond {http:#9923847} & Jester_48 {http:#9923927}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question