SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change <td> color via dropdown

    The following code only changes the color around the drop down menu and not the entire cell.

    Code:
    Choose a background color for this table cell:<br />
           <select onChange="this.parentNode.style.backgroundColor = this.options[this.selectedIndex].value;" name="bg_color_cell2" size="1">
            <option value="">-- Select a color --</option>
            <option style="background-color: #ffffff;" value="#ffffff">#ffffff</option>
            <option style="background-color: #ffff99;" value="#ffff99">#ffff99</option>
            <option style="background-color: #ccff99;" value="#ccff99">#ccff99</option>
            <option style="background-color: #ffcc99;" value="#ffcc99">#ffcc99</option>
            <option style="background-color: #cccc33;" value="#cccc33">#cccc33</option>
            <option style="background-color: #66cc99;" value="#66cc99">#66cc99</option>
          </select>

  2. #2
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    onChange="this.parentNode.parentNode.style.backgroundColor = this.options[this.selectedIndex].value;"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •