js 实现 combox
<SCRIPT LANGUAGE="JavaScript"> <!-- Begin function catch_keydown(sel) { switch(event.keyCode) { case 13: //Enter; sel.options[sel.length] = new Option("","",false,true); event.returnValue = false; break; case 27: //Esc; alert("text:" + sel.options[sel.selectedIndex].text + ", value:" + sel.options[sel.selectedIndex].value + ";"); event.returnValue = false; break; case 8: //Back Space; var s = sel.options[sel.selectedIndex].text; sel.options[sel.selectedIndex].text = s.substr(0,s.length-1); event.returnValue = false; break; } } function catch_press(sel) { sel.options[sel.selectedIndex].text = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode); sel.options[sel.selectedIndex].value = sel.options[sel.selectedIndex].value + String.fromCharCode(event.keyCode);
event.returnValue = false; } //End --> </script>
</head> <center> <select name="fh_cp" onKeyDown="catch_keydown(this);" onKeyPress="catch_press(this);" style="width:200px;"> <option></option> <option value="1">倒萨快递费</option> <option value="2">速度空间开始打飞机</option> </select> </center> </body> </html>