如果在頁面中想做一個下拉列表框,并且可以在里面輪入文字,下拉列表且可以根據文字的長度改變長度,那么以下代碼可以實現!
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name=iData size=10 ></td>
<td><input type=button οnclick=showSel(true) value="6" style=" #000000;border-left-width:0px;cursor:hand;font-family:Webdings;width:20;height:20;vertical-align:baseline;padding:1px;line-height:5px"></td>
</tr>
<tr>
<td colspan="2"><select id=qswh size=10 style="position:absolute;display:none" οnchange=selText(iData)>
<option value="32432">1</option>
<option>12 </option>
<option>123 </option>
<option>1234 </option>
<option>12345 </option>
<option>123456 </option>
<option>1234567 </option>
<option>12345678 </option>
<option>123456789 </option>
<option>1234567890 </option>
<option>12345678909 </option>
<option>123456789098 </option>
<option>1234567890987 </option>
<option>12345678909876 </option>
<option>123456789098765 </option>
<option>1234567890987654 </option>
<option>12345678909876543 </option>
<option>123456789098765432 </option>
<option>1234567890987654321 </option></select></td>
</tr>
</table>
<script>
function document.onclick(){
showSel(false)
}
function showSel(flag){
document.all.qswh.style.display=(flag?"block":"none")
window.event.cancelBubble=true;
}
function selText(obj){
obj.value=(document.all.qswh.options[document.all.qswh.selectedIndex].text)
//showSel(false)
}
</script>