Solved

Maintaining state

Posted on 2003-12-11
6
386 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
6 Comments
 
LVL 22

Accepted Solution

by:
pjedmond earned 63 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 62 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now