Jump to content

Archived

This topic is now archived and is closed to further replies.

Hellusius

onClick

Recommended Posts

I try to modify the background color when the usser clicks on a radiobutton, frankly nothing happens so far.

[code]
<form><br>
<input type="radio" name="bgcolor" onClick="document.bgcolor= class="Normal" checked>Normal</a><br>
<input type="radio" name="bgcolor" onClick="document.bgcolor= class="Light">Light</a><br>
<input type="radio" name="bgcolor" onClick="document.bgcolor= class="Dark">Dark</a><br>
</form>
[/code]

I put in the little CSS code which looks like this
[code]
<style type="text/css">
.dark {background-color: #335588};
.Light {background-color: #7799CC};
.Normal {background-color: #5577AA};
</style>
[/code]

ant suggestion why it doesn't work, cause I have seen it been done before

Share this post


Link to post
Share on other sites
The link in which they gave an example can be found [url=http://"http://www.javascriptkit.com/javatutors/event2.shtml"]here[/url]

Share this post


Link to post
Share on other sites
if you're going to use CSS, there's no use direct linking to the document.bgcolor property

just use the onClick to set the body class respectively
[code]<input type="radio" name="bgcolor" onClick="document.body.class="dark">[/code]

Share this post


Link to post
Share on other sites
I got it working now with the following code

[code]<input type="radio" name="bgcolor" onClick="document.bgColor='5577AA'">Normal</a><br>
<input type="radio" name="bgcolor" onClick="document.bgColor='7799DD'">Light</a><br>
<input type="radio" name="bgcolor" onClick="document.bgColor='335588'">Dark</a><br>[/code]

But now would I like to save it so it keeps having that background through all pages as well, is that a possiblity?

Share this post


Link to post
Share on other sites
I am still wondering how I can save the background color the visitor picked, is there a way?

Share this post


Link to post
Share on other sites

×

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.