onkeydown="clearSelect(this,event);" onkeypress="writeSelect(this,event);" style="width:70px;"> test1 test2 test3 <script> <BR>function clearSelect(obj,e) <BR>{ <BR>opt = obj.options[0]; <BR>opt.selected = "selected"; <BR>if((e.keyCode== 8) ||(e.charCode==8))//使用退格(backspace)键实现逐字删除的编辑功能 <BR>{ <BR>opt.value = opt.value.substring(0, opt.value.length>0?opt.value.length-1:0); <BR>opt.text = opt.value; <BR>} <BR>if((e.keyCode== 46) ||(e.charCode==46))//使用删除(Delete)键实现逐字删除的编辑功能 <BR>{ <BR>opt.value = ""; <BR>opt.text = opt.value; <BR>} <BR>//还可以实现其他按键的响应 <BR>} <br><br>function writeSelect(obj,e) <BR>{ <BR>opt = obj.options[0]; <BR>opt.selected = "selected"; <BR>opt.value += String.fromCharCode(e.charCode||e.keyCode); <BR>opt.text = opt.value; <BR>} <BR>function forbidBackSpace()//为了在IE中,避免backspace的返回上一页功能,和本下拉框的编辑功能冲突,需要禁掉backspace的功能。forbidBackSpace可以写在<body onkeydown="forbidBackSpace();">中。 <BR>{ <BR>if((event.keyCode == 8) && (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password")) <BR>{ <BR>event.keyCode = 0; <BR>event.returnValue = false; <BR>} <BR>} <BR></script>