这个例子实现的功能和CSDN提问时右侧那个检索差不多,但不够准确,请哪位帮忙修改一下!(准确、美观、方便)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
var arrList=null;
function init(){
var aa=document.getElementById("selId");
var opts=aa.options;
var len=opts.length;
arrList= new Array(len);
for(var i=0;i<len;i++)
arrList[i]=opts[i].value.toLowerCase();
}var oPopup = window.createPopup();
function keyup(src){
var oPopBody = oPopup.document.body;
oPopBody.style.backgroundColor = "lightyellow";
oPopBody.style.border = "solid black 1px";
var bb="";
var aa=document.getElementById("selId");
var len=src.value.length;
for(var i=0;i<arrList.length;i++){
if(arrList[i].substring(0,len)==src.value)
bb+='<option value="'+arrList[i]+'">'+arrList[i]+'</option>';
}
  oPopBody.innerHTML='<select id="selId" size="15" multiple style="width:300px;" onChange="parent.txtInput.value=this.options[this.selectedIndex].text;parent.txtInput.select()">'+bb+'</select>';
oPopup.show(5, 50, 300, 200, document.body);
}
//-->
</script>
<title></title></head>
<body onLoad="init();">
<input type="text" name="szm" id="txtInput" onkeyup="keyup(this)"> <a href="#" onClick="keyup(document.all.txtInput)">点击</a>
<div id="hidd" style="display:none;position:absolute; left:5px; top:50px; width:300px; height:200px; z-index:10">
<select id="selId" size="15" multiple style="width:300px;" onChange="txtInput.value=this.options[this.selectedIndex].text;txtInput.select()">
        <option value="http://www.163.com">http://www.163.org</option>
        <option value="http://www.sina.com">http://www.sina.com</option>
        <option value="http://www.sohu.com">http://www.sohu.com</option>
        <option value="611game">611掌机网</option>
        <option value="xvxvxzvx">xvxvxzvx</option>
        <option value="http://news.sohu.com">http://news.sohu.com</option>
  </select>
</div>
</body>
</html>