给你个例子:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
<script language=javascript>
function displayelement()
{
selectid=document.all.control.selectedIndex;
if (document.all.control.options[selectid].value=="abcde")
{
document.all.abcde.style.display="block";
document.all.button.style.display="none";
}
else
{
document.all.button.style.display="block";
document.all.abcde.style.display="none";
}
}
</script>
</head><body><form method="POST" action="--WEBBOT-SELF--">
<p><select size="1" name="control" onchange="displayelement();">
<option value="abcde">abcde</option>
<option>button</option>
</select>
<input type="text" name="button" size="20" style="display:none">
<select size="1" name="abcde" style="display:none">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select></p>
</form>
</body>
</html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
<script language=javascript>
function displayelement()
{
selectid=document.all.control.selectedIndex;
if (document.all.control.options[selectid].value=="abcde")
{
document.all.abcde.style.display="block";
document.all.button.style.display="none";
}
else
{
document.all.button.style.display="block";
document.all.abcde.style.display="none";
}
}
</script>
</head><body><form method="POST" action="--WEBBOT-SELF--">
<p><select size="1" name="control" onchange="displayelement();">
<option value="abcde">abcde</option>
<option>button</option>
</select>
<input type="text" name="button" size="20" style="display:none">
<select size="1" name="abcde" style="display:none">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select></p>
</form>
</body>
</html>
function showdiv(obj)
{
if(obj.options[obj.selectedIndex].text=="text")
mydiv.innerHTML="<input type=text>"
else
mydiv.innerHTML="<select><option>sel1<option>sel2</select>"
}
</script>
<select onchange=showdiv(this)>
<option>text
<option>select
</select>
<div id=mydiv></div>