Jump to content

change image with dropdown

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
bfly03

bfly03

    Newbie

  • Members
  • Pip
  • 1 posts
so far i have my dropdown menu changing out a link for me. is there a way for the same menu to change an image as well? ideas?

cheers,

<script type="text/javascript">

function dosomething() {

 var inputSelector = document.getElementById("myoptions");

 var link = document.getElementById("mylink");

 if (inputSelector.value == "black") {

 link.innerHTML = "Add to Cart";

 link.href = "#G400180,G410001";

 }

 if (inputSelector.value == "silver") {

 link.innerHTML = "Add to Cart";

 link.href = "#G400180,G410003";

 }

 if (inputSelector.value == "gold") {

 link.innerHTML = "Add to Cart";

 link.href = "#G400180,G410002";

 }

}

</script>

<select id="myoptions" onchange="dosomething()">

    <option value="black">Black Frame</option>

    <option value="silver">Silver Frame</option>

    <option value="gold">Gold Frame</option>

  </select>

<br /> <br />

        	  

  <a id="mylink" href="#G400180,G410001" class="add-items">Add to Cart</a>

Image I want to change:
<div id="image">

       	  <img src="../images/frames/black/400180.jpg" alt="400180" name="Lens400180" width="400" height="200" border="0" id="Lens400180" /></div>


#2
DarkLordofthePenguins

DarkLordofthePenguins

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 409 posts
document.getElementById('imageid').src = whatever;

I don't know if that's what you're looking for because your question is kind of vague, but I hope that helps.