View Full Version : changing radio bgcolor
fractalbit
04-21-2003, 03:08 AM
Hi. Can someone tell me how i can change the background color of a radio button? I am clueless. Thanks for any help.
shlagish
04-21-2003, 03:20 AM
Here is a way of doing it with javascript:
When you mouse over a table cell, the bgColor of the radio button will change
<html>
<head>
<script type="text/javascript">
function changeColor(color)
{
myForm.myRadio.style.background=color
}
</script>
</head>
<body>
<table width="100%"><tr>
<td bgcolor="red" onmouseover="changeColor('red')" height="20"> </td>
<td bgcolor="blue" onmouseover="changeColor('blue')"> </td>
<td bgcolor="green" onmouseover="changeColor('green')"> </td>
</tr></table>
<form name="myForm">
Mouse over the colors <input checked type="radio" id="myRadio">
</form>
</body>
</html>
Here is how to do it plainly with css
<html>
<head>
<style type="text/css">
<!--
.Radio { background-color: red; }
-->
</style>
</head>
<body>
<input type="radio" class="Radio">
</body>
</html>
or inline css
<html>
<body>
<input type="radio" style="background-color: red;">
</body>
</html>
P.S some of the codes I put might not work, I did not test them
fractalbit
04-21-2003, 03:24 AM
Thank you very very much. I tried the inline method and it worked perfectly. :thumbsup:
zoobie
04-21-2003, 08:42 AM
What would be cooler would be to forget the background and swap an image onclick making the radio button itself appear to have changed colors...heh heh. :cool:
shlagish
04-22-2003, 02:24 AM
:confused: I don't quite understand :confused:
zoobie
04-22-2003, 08:13 AM
A small javascript would define the image as a radio button...and once clicked, would swap the image and turn the radio button green or whatever...not it's background...but the button itself...and change it's status to checked. :cool:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.