Solved

Maintaining state

Posted on 2003-12-11
6
395 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

777 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