|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Changing colors in HTML tables with radio buttons
I want to be able to set up radio buttons to allow visitors to my website to be able to view my artwork with different colored backgrounds. The artwork sits inside tables, so I need a radio button color change script. I assume JavaScript would be the way to go.
I'm new to Java, but would like to learn how to do it. Any help would be appreciated. Changing the background would involve totally redesigning my website which I don't want to do. My website url is: http://www.robertterrell.com Thanks, berto_terrell |
|
#2
|
|||
|
|||
|
1. Add a wrapper div (styled with some padding) around your image:
Code:
<div id="imageWrapper" style="padding: 10px;"> <img src="reallyCoolPicture.gif" /> </div> 2. Build the radio buttons: Code:
<form>
<input type="radio" name="colorChange" onclick="changeBg ('red')" /> <label>red</label>
<input type="radio" name="colorChange" onclick="changeBg ('#fff')" /> <label>white</label>
<input type="radio" name="colorChange" onclick="changeBg ('blue')" /> <label>blue</label>
</form>
3. Sprinkle a little Javascript and you're good to go: Code:
<script>
function changeBg (color)
{
var obj = document.getElementById ("imageWrapper");
obj.style.backgroundColor = color;
}
</script>
|
![]() |
| Viewing: Dev Shed Forums > Web Design > Web Design Help > Changing colors in HTML tables with radio buttons |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|