SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Florida
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dropdown dependent thumbnails

    Could you help me with this:
    I have a dynamic dropdown, and need to display a color swatch (jpg) next to it when a value gets selected.
    Paths to swatches cannot be stored in DB, so if possible, they need to be simply connected with value in the dropdown (value1=value1.jpg)
    Is this do-able?

    PS: here is an example of color selection I need: http://www.wigs.com/product_info.php?products_id=3224

    Thank you

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function updateSwatch(pic) {
      document.getElementById("swatchGoesHere").src = pic;
    }
    
    ...
    
    <select onchange="updateSwatch(this.value);">
    <option value="red.jpg">red</option>
    <option value="green.jpg">green</option>
    <option value="blue.jpg">blue</option>
    </select>
    <img id="swatchGoesHere" src="nocolor.jpg">


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
  •