日期:2014-05-17 浏览次数:20965 次
<html>
<body>
<div>
<select name="year" id="year" onchange="change()">
<option value="33">33</option>
<option value="44">44</option>
<option value="55">55</option>
</select>
</div>
<div>
<img id="image" src="D:/image/66.gif" alt="嘿嘿"></img>
</div>
</body>
<script>
function change(){
var year=document.getElementById('year').value;
alert(year);
var image=document.getElementById("image");
image.src="D:/image/"+year+".gif";
}
</script>
</html>
我这D盘的image文件下面有,33,44,55,66.gif,经过测试通过!
<body>
年<select>
<option value="2012.jpg">2010</option>
<option value="2011.jpg">2011</option>
<option value="2012.jpg">2012</option>
</select>
<input type="button" onclick="querySrcImg()"><br/>
<img id="image" width="200px" />
</body>
<script type="text/javascript">
function querySrcImg(){
var srcImg document.getElementById("selYear").value;
document.getElementById("img").src = srcImg;
}
</script>
<script type="text/javascript">
$(document).ready(function(){
$("input").click(function(){
var srcImg = $("#selYear").val();
$.get("#img").src=srcImg;
});
})
</script>