function changeText()
{
var x=document.getElementById("tid");
var g = document.getElementById("g");
var go = x.options[x.selectedIndex].value;
switch (Number(go)){
case 0:
g.value = "0";
break;
case 1:
g.value = "1";
break;
case 2:
g.value = "2";
break;
case 3:
g.value = "3";
break;
default:
g.value = "de";
}
}
如上代码中从下拉列表的选项读出值类型是字符串,无法被switch使用,故加上类型转换。