Preserved Topic: DHTML, JavaScript and hiding DIV's |
|
---|---|
Author | Thread |
Nervous Wreck (II) Inmate From: |
posted 08-27-2001 20:08
I'm using div's with onclick's to hide and unhide certain tables by clicking on an image of a unchecked & checked box that I made. It works great, everything does as it should............... |
Paranoid (IV) Inmate From: 127.0.0.1 |
posted 08-27-2001 20:57 |
Nervous Wreck (II) Inmate From: |
posted 08-27-2001 21:21
Thought about cookies, but I don't want to do that unless it's the only option. |
Maniac (V) Mad Scientist with Finglongers From: Cell 53, East Wing |
posted 08-27-2001 21:31
Pugzly is right - cookies or if you want to go server side you could probably use sessions to record the final state of the page when the form is submitted (I'm not sure how tricky that would be but somewhere here might know). I'm not sure what your reluctance is - you could have a small message saying that browsers with cookies enabled will have a better experience on your page. |
Nervous Wreck (II) Inmate From: |
posted 08-27-2001 23:14
Well the reluctance is, now I gotta learn how to do cookies properly with DIV tags and onclick events. |
Maniac (V) Mad Scientist From: New California |
posted 08-27-2001 23:44
Yes, cookies. But sometimes pages just instruct you to hit the "back" button and that should retain the last page's state. I guess your page has an init function that resets everything? The only other way would be to save the information into a database and make sure you pass the user's id to each page. That is probably a lot more trouble than using the cookies. |
Nervous Wreck (II) Inmate From: |
posted 08-27-2001 23:54
So then, if I have 2 divs showing and the other like 4 divs hidden, this would save them as it is. |
Nervous Wreck (II) Inmate From: |
posted 08-28-2001 00:23
Well I tried your code with changing the purple to a different name in each place. And it doesn't save anything. When I go back to the page all my divs are setup the way they are default. No state is saved. |
Maniac (V) Mad Scientist From: New California |
posted 08-28-2001 01:01
Carnage, |
Nervous Wreck (II) Inmate From: |
posted 08-28-2001 01:14
Ok here is some of my code. |
Maniac (V) Mad Scientist From: New California |
posted 08-28-2001 02:29
Setting 6 cookies on someone's computer is not a big deal at all. The amount all the cookies allowed on one system is over a Gigabyte of data so six numbers and labels is hardly a problem. I'm not sure how an array would help but you could store a cookie with a bit map value. Something like "001000" for the third div turned on and the rest off. But you would need to parse that value. If you only have 6, I would just set one for each check. As far as getting rid of them when all is cool, all you need to do is set the expire date to a past date. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 08-28-2001 04:15
Keep in mind that browsers dont have to store more than 20 cookies for your server, and no more than 300 for the entire internet, so if you can put lots of data in a single cookie, it's generally a good idea to do so. You're allowed 4 kb per cookie. |
Nervous Wreck (II) Inmate From: |
posted 08-28-2001 06:54
Slime: is there a good place to figure out how to set these things using arrays? |