js把字符串类型转换成数字型

<script>
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”;
}
}
</script>
<select name=”tid” id=”tid” class=”BigSelect” onchange=”changeText()” >
<option value=”0″>–请选择类型–</option>
<option value=”1″>abc</option>
<option value=”2″>abc2</option>
<option value=”3″>a3bc</option>
<input type=”text” id=”g” value=”a”>
</select>
如上代码中从下拉列表的选项读出值类型是字符串,无法被switch使用,故加上类型转换。