Click to See Complete Forum and Search --> : Using a Cookie!


tomyknoker
06-21-2003, 07:31 PM
Hi All,
I want to make a form with four fields, one of them asking for the users favourite BG color. This I don't have a problem with, but I want this information to be stored into a cookie.

And then I want another page that reads these cookies and prints out all the information stored in the cookie formateed in a way that states what the user said from the last page (eg "You said your favourite music was pop" where pop was entered by them on the previous page. Also I would like to set the bgcolor of the new page to be what they said there favourite color was in the previous page,

Thanks everyone in advance,
Tom

Jona
06-21-2003, 07:34 PM
You could also use a query string instead of setting a cookie, but whatever you like is fine I suppose. I have already created a script very much like this. You may look at it here. (http://jona.t35.com/experiments/funcookies1.html)

Jona

tomyknoker
06-21-2003, 07:38 PM
Oh that is fantastic! but how would I make it chnage the BG color if they pick pink? and is it easy to add more info to enter for the form?

Jona
06-21-2003, 07:39 PM
Yes, if you'd like me to write out more information on this I'd be happy to teach you. Also, making it turn into the BGColor instead of the text color is no difficulty either.

Jona

tomyknoker
06-21-2003, 07:45 PM
Hi Jona,
yes I would like to learn how to do it if you could show me thanks,
tom

Jona
06-21-2003, 07:47 PM
Here's what I'll do. I'll be back in about an hour or so and post a link to a page with a tutorial on it. I've been needing to do this anyways. Also, I will modify the script so that you can get it to work with the background color instead of text color.

Jona

tomyknoker
06-21-2003, 07:49 PM
thanks alot jona!

Jona
06-21-2003, 09:24 PM
Just so you know, the hard coding tutorial doesn't exist yet, so you'll get a 404 error if you click the link, but anyways... Here is the tutorial. (http://jona.t35.com/experiments/funcookies_tutorial.html) Have fun! You should learn enough to be able to make the script change the background color. If you have any other questions, feel free to ask.

Jona

tomyknoker
06-22-2003, 05:07 AM
hey jona,
went through the tutorial, thanks again it was heaps helpful! I am still having a bit of trouble when I have other entries in the form, besides just favourite color. and also can't seem to get the bgcolor to change...
thanks, tom

Jona
06-22-2003, 02:23 PM
It's simple enough, really. Take off the starting <BODY> tag from the source code of the second page, and replace the document.write() part with this:


document.write("<body bgcolor="+theColor+">");


Jona