求在列表框中选择一个值时显示一个文本框的JS代码 在列表框中选择一个值时,显示一个文本框,再选择其他值时,文本框消失。 类似于某些网站注册时的密码问题“自定义问题” 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>无标题页</title> <script type="text/javascript"> var text; function createText(obj){ if(obj.value=="3"){ text=document.createElement("input"); text.setAttribute("type","text"); document.getElementById("text").appendChild(text); } else if(document.getElementById("text").hasChildNodes()){ document.getElementById("text").removeChild(text); } } </script></head><body> <form id="form1" runat="server"> <div> <select name="select" onchange="createText(this);"><option value="1">1</option><option value="3">2</option><option value="2">3</option></select> </div> <div id="text"></div> </form></body></html> 感谢楼上的回答,不过我找到了一个更简单点的办法<script language=JavaScript> function eyun(v) {if(v=="其他"){ form1.cartype2.style.display=''; } else form1.cartype2.style.display="none"; } </script><form name="form1"> <select name="cartype" id="cartype" onchange="eyun(this.value)"> <option>普桑</option> <option>桑塔纳3000</option> <option>捷达</option> <option>夏利</option> <option>远舰</option> <option>爱丽舍</option> <option value="其他">其他</option> </select><input name="cartype2" id="cartype2" type="text" size="12" style="display:none;"/></form> js如何调用vb的dll? 改变button的value,也就是改变按钮上的标题 注册用户名输入验证代码失灵,恳请高手指点 关于js浮动条与iframe嵌入mht文件的问题 asp.net调用前台自定义的js函数 js给多个图片添加事件时的传值问题(很急) 求一个判断,要求是数字加空格一共14位. 如何动态地给js传值?急!! 大虾们,谁能给判断非空,判断email,判断是数字这样的jscript 函数阿? 如何让鼠标点击一组radio中的一个,相应的变化<select><option>中的选项? 如何将事件的参数在外部传递给函数 如何用js获取树节点的中文名字
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
var text;
function createText(obj){
if(obj.value=="3"){
text=document.createElement("input");
text.setAttribute("type","text");
document.getElementById("text").appendChild(text);
}
else if(document.getElementById("text").hasChildNodes()){
document.getElementById("text").removeChild(text);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<select name="select" onchange="createText(this);">
<option value="1">1</option>
<option value="3">2</option>
<option value="2">3</option></select>
</div>
<div id="text"></div>
</form>
</body>
</html>
<script language=JavaScript>
function eyun(v)
{if(v=="其他"){
form1.cartype2.style.display='';
}
else
form1.cartype2.style.display="none";
}
</script>
<form name="form1">
<select name="cartype" id="cartype" onchange="eyun(this.value)">
<option>普桑</option>
<option>桑塔纳3000</option>
<option>捷达</option>
<option>夏利</option>
<option>远舰</option>
<option>爱丽舍</option>
<option value="其他">其他</option>
</select>
<input name="cartype2" id="cartype2" type="text" size="12" style="display:none;"/>
</form>