不知道哪里出错了,图片一直出不来
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Image Objcet</title>
<script language="javascript">
var image1 = new Image();
image1.src = "images\1.jpg";
var image2 = new Image();
image2.src = "images\2.jpg";
var image3 = new Image();
image3.src = "images\3.jpg";
 
 function loadCached(list){
     var img = list.options[list.selectedIndex].value;
 document.thumbnail.src = eval(img + ".src");
 }
</script>
</head>
<body>
<h2>Image Object</h2>
<img src="images\1.jpg" name="thumbnail" height="90" width="120" />
<form>
<select name="cached" onchange="loadCached(this)">
 <option value="image1">Bands
 <option value="image2">Clips
 <option value="image3">Lamp
</select>
</form>
</body>
</html>

解决方案 »

  1.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Image Objcet</title>
    <script language="javascript">
    var image=["images\\1.jpg","images\\2.jpg","images\\3.jpg"]; 
     function loadCached(list){
      var img = list.selectedIndex;
      alert(image[img]);
      
    document.thumbnail.src =image[img];
     }
    </script>
    </head>
    <body>
    <h2>Image Object</h2>
    <img src="images\1.jpg" name="thumbnail" height="90" width="120" />
    <form>
    <select name="cached" onchange="loadCached(this)">
     <option value="image1">Bands
     <option value="image2">Clips
     <option value="image3">Lamp
    </select>
    </form>
    </body>
    </html>
      

  2.   


    <img src="images\1.jpg" name="thumbnail" height="90" width="120" id="thumbnail" />
    <form>
    <select name="cached" onchange="loadCached(this)">
     <option value="images\1.jpg">Bands</option>
     <option value="images\2.jpg">Clips</option>
     <option value="images\3.jpg">Lamp</option>
    </select>
    function loadCached(list){
    document.getElementById('thumbnail').src =list.value;
     }