这个JS函数应该怎么写啊 小弟求大哥们帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/22 21:55:30
<tr>
<td >
<select name="select">
<option value ="1" SELECTED>请选择</option>
<option value ="2">生病</option>
<option value="3">家庭原因</option>
<option value="4">怀孕</option>
<option value="5">其他</option>

</select>
<input type="text" name="textfield" style="display:none"/>
</td>
</tr>

有一个下拉框当选择的是其他的时候 隐藏的text框就会显示出来并且聚焦可以输入内容 当下拉框选择的是别的不是其他这个选项的话就隐藏text框
这个function 该怎么写啊 大哥们帮帮小弟 感激不尽了 在线等

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
<!--
function showText(){
var vSltVal = document.getElementById("slt").value;
if(vSltVal == 5){
document.getElementById("otherTxt").style.display = "block";
}else{
document.getElementById("otherTxt").style.display = "none";
}
}
-->
</script>
</head