Web Hosting Talk







View Full Version : Color Picker | Changer


raulgonzalez
06-27-2007, 09:10 AM
Hello,

I use a color picker that uses a textbox to send the code for the color to a php. Then the color is kept in a cookie and the script sends back the visitor to the original page, and that's it, they have a new personalized color.

Now, I see that yahoo and msn have a color picker that all it requires is the user to click on it and the color is changed, seems like no server side process goes on unless it is Ajax based. :confused:

I was wondering if anyone had something similar to that, or a tutorial that I could go read up and integrate in my site. I found a few javascript based ones which do the same, but the color is gone as soon as I refresh the browser. I will keep searching.

Thanks

epcmedia
06-27-2007, 09:27 AM
If all ou are doing is changing the background color or something similar this is easy.

You can use javascript to set the color AND set a cookie for your pages to use on refreshes.

Lookup document.cookie for usage and examples.

Sample workflow:

user chooses color from picker
onclick event causes color change AND sets cookie (document.cookie)
user refreshes / clicks off page
php script eats cookie from browser and sets background colorThis way changes are propagated to subsequent requests.

EPCMEDIA