image.src에 각 <option>
의 값이 아닌 id를 표시하고 싶습니다. 방울 떨어 졌어 .ID는 존재하니? 이 작업을 수행 할 수 있습니까? 또는 ID가 <select>
에 잠겨 있습니까? 사용자가 제출을 명중 할 때, 나는 모양에있는 가치를 통과 할 필요가있다.dropped.value가 삭제되었습니다 .id가 있습니까?
<script type="text/javascript">
function swapImage(){
var image = document.getElementById("imageToSwap");
var dropped = document.getElementById("changethisimage");
image.src = "http://foo.com/images/"+dropped.value;
};
</script>
<img id="imageToSwap" src="http://foo.com/images/SHOP_Car Emblem.jpg" width="150" align=right>
<select name="os0" id="changethisimage" onChange="swapImage()">
<option value="Light Blue" id="SHOP_Car Emblem_Cyan.jpg" selected>Light Blue
<option value="Dark Blue" id="SHOP_Car Emblem_DkBlue.jpg">Dark Blue
<option value="Canadian Red" id="SHOP_Car Emblem_Red.jpg">Canadian Red
<option value="Irish Green" id="SHOP_Car Emblem_IrishGreen.jpg">Irish Green
</select>
'
또한 id 값에 공백이 없어야합니다. – jfriend00
Google에서 html 데이터 속성을 사용하는 경우 id를 URL로 전달하는 것보다 바람직합니다. – Andre