首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

可以输入的Select上拉框

2012-10-06 
可以输入的Select下拉框html xmlnshttp://www.w3.org/1999/xhtmlheadmeta http-equivContent-Ty

可以输入的Select下拉框

<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>可以输入的select标签</title> </head><body><select id="select" onkeydown="Select.del(this,event)" onkeypress="Select.write(this,event)">       <option value=""></option>       <option value="11">11</option>       <option value="22">22</option>       <option value="33">33</option>   </select>   <input type="button" value="点我" id="test" onclick="test();"/>   <script>    var Select = {       del : function(obj,e){           if((e.keyCode||e.which||e.charCode) == 8){               var opt = obj.options[0];               opt.text = opt.value = opt.value.substring(0, opt.value.length>0?opt.value.length-1:0);           }       },       write : function(obj,e){           if((e.keyCode||e.which||e.charCode) == 8)return ;           var opt = obj.options[0];           opt.selected = "selected";           opt.text = opt.value += String.fromCharCode(e.charCode||e.which||e.keyCode);              }   }     function test(){       alert(document.getElementById("select").value);   }   </script>   </body></html>
?

热点排行