Jump to content


Photo

onClick


  • Please log in to reply
6 replies to this topic

#1 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 30 July 2006 - 06:32 AM

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

<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>

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

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

#2 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 30 July 2006 - 07:26 AM

The link in which they gave an example can be found here


#3 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 30 July 2006 - 07:45 AM

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
<input type="radio" name="bgcolor" onClick="document.body.class="dark">

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#4 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 30 July 2006 - 09:19 AM

The akward thing is, that it does not change my background of the page  ???

#5 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 30 July 2006 - 10:24 AM

I got it working now with the following 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>

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

#6 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 03 August 2006 - 11:01 PM

I am still wondering how I can save the background color the visitor picked, is there a way?

#7 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 04 August 2006 - 01:59 AM

use a cookie.

http://www.w3schools.../js_cookies.asp




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users