Javascript 运行多个Java脚本以更改图像
有问题,我不能得到两者都改变只有1将工作,我需要两个切换到我的网站上工作的任何帮助将不胜感激 提前感谢Javascript 运行多个Java脚本以更改图像,javascript,image,Javascript,Image,有问题,我不能得到两者都改变只有1将工作,我需要两个切换到我的网站上工作的任何帮助将不胜感激 提前感谢 这是我的代码,我想它有你需要的一切,你可以看到它到底在做什么 <html> <body> <img id="imageToSwap" src="http://ideviceguys.com/wp- content/uploads/2013/09/blkscreen.png" /> <br/><br/&g
这是我的代码,我想它有你需要的一切,你可以看到它到底在做什么
<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>
黑色
白色
浅蓝色
黄色的
粉红色
红色
函数swapImage(){
var image=document.getElementById(“imageToSwap”);
var dropd=document.getElementById(“屏幕”);
image.src=dropd.value;
};
黑色
白色
浅蓝色
黄金
粉红色
红色
函数swapImage(){
var image=document.getElementById(“colorframes”);
var dropd=document.getElementById(“框架”);
image.src=dropd.value;
};
像这样吗
我补充说
var image2 = document.getElementById("colorframes");
image2.src = dropd.value;
我想这是两个独立的页面。哪个有效,哪个无效?请注意,在您的第一页中,有几个URL包含一些虚假的空格,这会给您带来麻烦,除非它们是复制粘贴的产物。image switcher,不,我需要在一个页面上同时使用它们