28,390
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<style>
<!--
body{font-size:12px;}
#show{border:1px solid #9abcde; line-height:23px; width:200px; margin:0px;}
#show li{list-style:none;}
#sug{margin:0px auto;}
.style1 {font-size: x-large}
-->
</style>
<script language="javascript">
<!--
var xmlHttp = false;
function ajaxcreate(){
try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
if(!xmlHttp){alert('Create Xmlhttp Fail ');return false;}
}
function sugguest(){
ajaxcreate();
var xmvalue=document.getElementById("key").value;
//var url="post.ASP?key="+encodeURI(xmvalue)+"&rnd="+Math.random();
var url="post.ASP?key="+(xmvalue)+"&rnd="+Math.random(1);
if (xmvalue== null || xmvalue.length>20 || xmvalue == "") return false;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(xmvalue);
xmlHttp.onreadystatechange=returnstate;
}
function returnstate(){
if(xmlHttp.readyState != 4 ){
document.getElementById("sug").innerHTML="plase wait....";
}
if(xmlHttp.readyState == 4 ){
document.getElementById("sug").innerHTML=xmlHttp.responseText;
}
}
function fillin(str){
document.getElementById('key').value=str;
obj =document.getElementById('sug');
obj.innerHTML='';
obj.style.display='none';
}
function other(){
document.getElementById('sug').style.display='block';
}
function losefouse(){
setInterval("func()",4000);
var time=setInterval("func()",1000);
clearTimeout(time);
}
function func(){
ob=document.getElementById('sug');
ob.style.display = 'none';
}
-->
</script>
<body >
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="post" action=""><tr>
<td>
<input name="key" type="text" id="key" onFocus="other();" onKeyDown="sugguest();" onBlur="losefouse();" size="27" autocomplete=off >
<input type="submit" name="Submit" value="搜索">
</td>
</tr></form>
<tr>
<td><div id="sug" onClick="javascript:func();"></div></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
<%
Response.charset="GB2312"
DB="db.mdb"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&DB&"")
'On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请联系管理员。"'
Response.End
End If
key=Request.QueryString("key")
set rs = server.CreateObject ("adodb.recordset")
sql="select * from tbale where title like '%"&key&"%' order by id desc"
rs.open sql,conn,1,1
response.Write("<div id=show >")
if not rs.bof then
do while not rs.eof
response.Write("<li onMouseOver=""this.style.background='#d7ebff'"" onMouseOut=""this.style.background='#ffffff'"" onclick=""javascript:fillin(this.innerHTML);"">"&rs("title")&"</li>")
rs.movenext
loop
else
response.Write key
end if
response.Write("</div>")
%>