dropdown box image swap not working for IE!

Discussion in 'JavaScript' started by erkerr67, Apr 13, 2009.

  1. #1
    Hello, hoping someone can help me out with this! I'm doing a basic image swap from a simple html form text dropdown box. You select the specified text from the dropdown box and it swaps out the image with another image corresponding to that text somewhere else on the page.

    I have this working well in Firefox, no problems at all. But when I test it in IE7, nothing happens (of course, right?)... any ideas? Makes me sad :(

    Now I'm not sure if this is the most effecient way of building this but it's how a beginner like me put it together....basic onmousedown functions within the form. ...does IE not read these because they're placed within a form? I have no clue! help!

    Anyway, here's my code:

    <div class="form">
    <form action="">

    <select name="extend" class="custom">
    <option value="not-extended" selected="selected" onmousedown="if(document.getElementById('extend2').style.display == 'none'){ document.getElementById('extend2').style.display = 'block'; document.getElementById('extend').style.display = 'none'; } ">not extended</option>

    <option value="extended" onmousedown="if(document.getElementById('extend').style.display == 'none'){ document.getElementById('extend').style.display = 'block'; document.getElementById('extend2').style.display = 'none'; } ">Extended</option>
    </select>

    </form>
    </div>

    i have no idea why this doesn't execute at all in explorer!! :(

    and here's a scrap link that gives you an idea of what im trying to do....
    http://208.179.155.80/customizer.html
    (look at the snap-valve type/extended option - the rest dont do anything yet, only that one should be functioning)
     
    erkerr67, Apr 13, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    not sure, seems ok as swap code (not optimal as it will leak memory but still) - try to ditch onmousedown, use onchange on the parent or onselect or even onclick instead.
     
    dimitar christoff, Apr 14, 2009 IP