在下拉框中输入文字
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<script language=javascript >
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 46: //Delete; 
if(confirm("刪除當前內容!?")) { 
sel.options[sel.selectedIndex] = null; 
if(sel.length>0) { sel.options[0].selected = true; } } 
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); event.returnValue = false;
}

</script>
<select onkeydown="catch_keydown(this);" onkeypress="catch_press(this);"><option>a</option><option>b</option></select>
</body>
</html>
浙公网安备 33010602011771号