Nguyễn Kiên Cường
(Steady)
Moderator
Không hiểu sao đoạn script sau chạy tốt với IE mà nếu dùng Mozilla thì lại không chạy nhỉ?
---------------------------------------------
<html>
<head>
<script language="JavaScript" type="text/JavaScript"><!--
function init_item_photo(){
if (document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id]; }
}
oItem_photo = document.getElementById("item_photo");
oItem_photo_arr = new Object();
oItem_photo_arr["White"] = new Image;
oItem_photo_arr["White"].src = "white.gif";
oItem_photo_arr["Yellow"] = new Image;
oItem_photo_arr["Yellow"].src = "yellow.gif";
oItem_photo_arr["Pink"] = new Image;
oItem_photo_arr["Pink"].src = "pink.gif";
} //end for Init_item_photo();
function changeItem(){
oItem_photo.src = oItem_photo_arr[select_color.value].src;
}
//--></script>
</head>
<body onLoad="init_item_photo();">
<img src="white.gif" width="250" id="item_photo">
<select name="select_color" onChange="changeItem();">
<option value="White" selected>white</option>
<option value="Yellow" >yellow</option>
<option value="Pink" >pink</option>
</select>
</body>
</html>
---------------------------------------------
<html>
<head>
<script language="JavaScript" type="text/JavaScript"><!--
function init_item_photo(){
if (document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id]; }
}
oItem_photo = document.getElementById("item_photo");
oItem_photo_arr = new Object();
oItem_photo_arr["White"] = new Image;
oItem_photo_arr["White"].src = "white.gif";
oItem_photo_arr["Yellow"] = new Image;
oItem_photo_arr["Yellow"].src = "yellow.gif";
oItem_photo_arr["Pink"] = new Image;
oItem_photo_arr["Pink"].src = "pink.gif";
} //end for Init_item_photo();
function changeItem(){
oItem_photo.src = oItem_photo_arr[select_color.value].src;
}
//--></script>
</head>
<body onLoad="init_item_photo();">
<img src="white.gif" width="250" id="item_photo">
<select name="select_color" onChange="changeItem();">
<option value="White" selected>white</option>
<option value="Yellow" >yellow</option>
<option value="Pink" >pink</option>
</select>
</body>
</html>