Jump to content

Toggle background colour


dreampho

Recommended Posts

Hi. I am looking for a way to have a button that toggles the background colour of my website.

 

So for instance, I will have one button called 'switch to light', when its clicked it switches the colour of the background to a light colour, and another button replaces this that says 'switch to dark', and so on. I have turned to PHP because it appears to be the only way I would be able to have the change saved throughout the site, when pages are refreshed. However, I am a complete newbie, so have no idea what to do!

 

Anyone that can help is a life saver!

 

Thanks

 

Link to comment
Share on other sites

Your question is very vague. If you are looking for someone to type this for you it has already been done a thousand times a thousand different ways using many different languages. (P.S. Google is your friend)....

 

No matter how you do this whether you use php or javascript you are going to be saving the color information to a cookie or to the session you will then retrieve this information to display across the site. Both languages are perfectly capable of doing what you need. You could actually use the database too so that you could make this change even more persistent, but after a few searches you should be able to find some information.

 

I am sure there are many people here who would be more than happy to help you with "YOUR" code so if you have any questions about your code feel free to post them and you will get help much faster.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.