Change background colour with button?

Hello there... New to ccs :S

I would like to be able to change the background colour of my webby using a button.

my website is here;

<!-- m --><a class="postlink" href="http://www.directentrystudents.net/">http://www.directentrystudents.net/</a><!-- m -->

The actual position of the button is down the right hand side on the accessibility options...

Now, I think I have the code to present the button;

<button style="width: 45px; height: 25px; background-color: #ffffcc" onclick="changecolor('FFFFCC');"></button>

But firstly

1) I dont know if this is the right code..
2) Do I have to have anything placed in my css file which has a link placed at the top of my page;
<link rel="stylesheet" type="text/css" href=http://www.webdeveloper.com/forum/archive/index.php/"DES.css"/>

Do I have to put something in the DES.css file. Or do I have to assign each button a .class. As you can see, im clueless... I have had a quick search but could not find anything, and I have spent a long time trying to get it running, without success.

Any tips would be welcomed, or indeed point me in the right if possible.. I'll go a hunting for the answer.

Thank you very much for your assistance..

SpenceAnyone have ideas then please. This can be done, Ive seen a site which does it.

Thank youSee if this works:

<button style="width: 45px; height: 25px; background-color: #ffffcc" onclick="document.bgColor='#FFFFCC';"></button>See if this works:

<button style="width: 45px; height: 25px; background-color: #ffffcc" onclick="document.bgColor='#FFFFCC';"></button>


Thank you very very, very, much. Have a great day!

Works like a charm!I dont suppose there is a way to keep the background colour throughout the whole site.

When the user clicks on a button, it does change the colour. But when they go to a different page the colour changes back to the default white.

Thanks again for your help.

Spence

<!-- w --><a class="postlink" href="http://www.directentrystudents.netYou'd">www.directentrystudents.netYou'd</a><!-- w --> have to do something like set a cookie, then read that cookie on each page to set the default color. I'd suggest searching the JavaScript forum, and if it's not already answered, then post this question there.Make different external stylesheets for each, then use a combination of javascript and either php or asp to set a session variable.

Once you set that session variable, have a check for including the corresponding stylesheet.

$var = $_SESSION['color'];

if($var == "1") {
print "<link rel="stylesheet" type="text/css" src=http://www.webdeveloper.com/forum/archive/index.php/"/styles/red.css";
elseif($var == "2")

and so on

example.

<!-- m --><a class="postlink" href="http://www.villageofhoward.comMake">http://www.villageofhoward.comMake</a><!-- m --> different external stylesheets for each, then use a combination of javascript and either php or asp to set a session variable.

Once you set that session variable, have a check for including the corresponding stylesheet.

$var = $_SESSION['color'];

if($var == "1") {
print "<link rel="stylesheet" type="text/css" src=http://www.webdeveloper.com/forum/archive/index.php/"/styles/red.css";
elseif($var == "2")
and so on
example.
<!-- m --><a class="postlink" href="http://www.villageofhoward.com">http://www.villageofhoward.com</a><!-- m -->

Hi there. Thank you very much indeed for your response. However Im very new to CSS and JS and PHP (lool) so I dont really know what your talking about.

I only know what I have learned thus far. I know the session var on my site stores the user_is and gets this from the register_db.


When you say make a different syle sheet for each button, or button code;


<button style="width: 45px; height: 25px; background-color: #ffffcc" onclick="document.bgColor='#FFFFCC';"></button> <red>


So a seperate stlye sheet for this button, and all the rest..

Sorry, im just trying to learn. I have searched the JS forum, but cannot see anything. I will post this message there.

Thanks again for helping an oldie out.

Spence

PS: This site has it, Im trying to look at how he has done it through the source, but cannot figure it out... can you ?

<!-- m --><a class="postlink" href="http://stuweb.cms.gre.ac.uk/~kv208/HCI/index.php?bgcolour=DDDDDD&image=show&usmenu=s">http://stuweb.cms.gre.ac.uk/~kv208/HCI/ ... w&usmenu=s</a><!-- m -->

thanks
 
Back
Top