[CODE]<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<DIV style="width:200px; height:27px;">
<DIV id="listDiv" style="width:100%; display:none;">
<select id="inputList" style="width:100%;" onChange="ShowObj(this);">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</DIV>
<DIV id="textDiv" style="width:100%; display:;">
<input id="inputText" type="text" style="width:100%;" onDblClick="ShowObj(this);">
</DIV>
</DIV>
双击文本框看效果!
<SCRIPT LANGUAGE="JavaScript">
<!--
function ShowObj(Obj){
var Obj1 = document.getElementById("inputList")
var Obj2 = document.getElementById("inputText")
if(Obj==Obj2){
textDiv.style.display="none";
listDiv.style.display="";
Obj1.options.add(new Option(Obj.value,Obj.value));
var OptLen=Obj1.options.length-1;
Obj1.options[OptLen].selected=true;
}else if(Obj==Obj1){
listDiv.style.display="none";
textDiv.style.display="";
Obj2.value = Obj1.options[Obj1.selectedIndex].value;
}
}
//-->
</SCRIPT>
</BODY>
</HTML>[/CODE]
个人改了一下代码的效果。