日期:2014-05-16  浏览次数:20331 次

求一JS....
效果:
当下拉菜单1   选择第一项时,显示下拉菜单2  
选择第二项时,显示一个输入TEXTBOX

谢谢~~50分相送

------解决方案--------------------
<select onchange= "a(this) ">
<option> 1
<option> 2
</select>
<select id=n1 style= "display:none "> </select>
<input id=n2 style= "display:none ">

<script>
function a(o)
{
n1.style.display= "none "
n2.style.display= "none "
document.getElementById( "n " +o.options[o.selectedIndex].text).style.display= "none "
}
</script>
------解决方案--------------------
<html>
<head>
<script type= "text/javascript ">
<!--

function dlChg(src){
var idx = src.selectedIndex;
for(var i=0;i <src.options.length;i++){
var div = document.getElementById( "dltdiv "+i);
if(div)
div.style.display = "none ";
}
document.getElementById( "dltdiv "+idx).style.display = "block ";
}
//-->
</script>
</head>
<body>
<select id= "dlt " style= "width:200px; " onchange= "dlChg(this) ">
<option value=1> 1 </option>
<option value=2> 2 </option>
<option value=3> 3 </option>
</select>
<div id= "dltdiv0 " style= "display:none;width:200px; "> <select> <option> 你选择了optioin 1 </option> </select> </div>
<div id= "dltdiv1 " style= "display:none;width:200px; "> <input type= "text " value= "你选择了optioin 2 "> </div>
<div id= "dltdiv2 " style= "display:none;width:200px; "> <input type= "text " value= "你选择了optioin 3 " style= "color:red "> </div>
</body>
</html>