SunQuest
           Web Design Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignWeb Design Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 4th, 2004, 05:46 PM
berto_terrell berto_terrell is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Lubbock, Texas
Posts: 1 berto_terrell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old October 10th, 2004, 10:21 AM
pocketsized pocketsized is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Brunei
Posts: 155 pocketsized User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 42 m 45 sec
Reputation Power: 5
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>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignWeb Design Help > Changing colors in HTML tables with radio buttons


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway