-1

有问题我不能让两者都改变​​只有 1 将工作,我需要两个切换器在我的网站上工作任何帮助将不胜感激提前谢谢
这是我的代码我认为它有你需要的一切来看看它到底在做什么

   <html>
    <body>

     <img id="imageToSwap" src="http://ideviceguys.com/wp- content/uploads/2013/09/blkscreen.png" />

     <br/><br/>

     <select id="screens" onChange="swapImage()">
     <option value="http://ideviceguys.com/wp-   content/uploads/2013/09/blkscreen.png">Black</option>
    <option value="http://ideviceguys.com/wp-content/uploads/2013/09/whtscreen.png">White</option>
     <option value="http://ideviceguys.com/wp-content/uploads/2013/09/ltbluescreen.png">Light Blue</option>
     <option value="http://ideviceguys.com/wp-content/uploads/2013/09/yellowscreen.png">Yellow</option>
     <option value="http://ideviceguys.com/wp-content/uploads/2013/09/pinkscreen.png">Pink</option>
    <option value="http://ideviceguys.com/wp-content/uploads/2013/09/redscreen.png">Red</option>
   </select>
    <script type="text/javascript">
    function swapImage(){
var image = document.getElementById("imageToSwap");
var dropd = document.getElementById("screens");
image.src = dropd.value;    
    };
 </script>
 </body>
 </html>


<html>
<body>

 <img id="colorframes" src="http://ideviceguys.com/wp-content/uploads/2013/09/blkframe.png" />

<br/><br/>

  <select id="frames" onChange="swapImage()">
  <option value="http://ideviceguys.com/wp-content/uploads/2013/09/blkframe.png">Black</option>
  <option value="http://ideviceguys.com/wp-content/uploads/2013/09/whtframe.png">White</option>
  <option value="http://ideviceguys.com/wp-content/uploads/2013/09/ltblueframe.png">Light Blue</option>
 <option value="http://ideviceguys.com/wp-content/uploads/2013/09/goldframe.png">Gold</option>
 <option value="http://ideviceguys.com/wp-content/uploads/2013/09/pinkframe.png">Pink</option>
 <option value="http://ideviceguys.com/wp-content/uploads/2013/09/redframe.png">Red</option>
 </select>
 <script type="text/javascript">
 function swapImage(){
var image = document.getElementById("colorframes");
var dropd = document.getElementById("frames");
image.src = dropd.value;    
   };
   </script>
   </body>
   </html>
4

1 回答 1

0

像这样?http://jsfiddle.net/DNYm4/

我添加了

      var image2 = document.getElementById("colorframes");
      image2.src = dropd.value;
于 2013-09-01T22:02:11.360 回答