日期:2014-05-16 浏览次数:20482 次
<script> function show(n){ document.getElementById("a1").style.display="none"; document.getElementById("a2").style.display="none"; document.getElementById("a"+n).style.display=""; } </script> <select onchange="show(this.options[this.selectedIndex].value)"> <option value="1">1</option> <option value="2">2</option> </select> <input id="a1" value="a1"> <input id="a2" value="a2" style="display:none;">
------解决方案--------------------
<html>
<body>
<script language="javascript" type="text/javascript">
function excu(obj)
{
if(obj==0)
{
document.getElementById("text1").style.display = "block";
document.getElementById("text2").style.display = "none";
}
else
{
document.getElementById("text2").style.display = "block";
document.getElementById("text1").style.display = "none";
}
}
</script>
<select name="sel" onchange="excu(this.options[this.selectedIndex].value);">
<option value="0">0</option>
<option value="1">1</option>
</select>
<br />
<input type="text" id="text1" value="txt0"/>
<input type="text" id="text2" value="txt1"/>
</body>
</html>
------解决方案--------------------
window.onload=function() { $("txt1").style.display=$("txt2").style.display='none'; } function change(obj) { if(obj.options[0].selected) { $("txt1").style.display=''; $("txt2").style.display='none'; } else { $("txt1").style.display='none'; $("txt2").style.display=''; } } function $(objID) { return document.getElementById(objID); }