ASP+AJAX做类似google的搜索提示(3)_ASP教程
教程Tag:暂无Tag,欢迎添加,赚取U币!
推荐:如何用Asp取得数据库中所有表名和字段名% set rs=server.CreateObject(adodb.recordset) db= db.mdb '只要直接更改数据库名称就能够看到效果了。 set conn=server.CreateObject(adodb.connection) connstr=Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Server.MapPath(db) conn.open c
第三个文件:conn.asp
[code=vbscript]
<%
set conn = Server.CreateObject("Adodb.Connection")
connStr = "Provider=SQLOLEDB;Server=.\SQLEXPRESS;UID=sa;PWD=sa;Initial catalog=test;"
conn.ConnectionString = connStr
conn.open
%>
[/code]
第四个文件:search.asp
[code=vbscript]
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!-- #include file="conn.asp" -->
<%
key = request.QueryString("key")
if (key <> "") then
key = replace(key,"\","")
key = replace(key,"’","")
key = replace(key,"or","")
sel_sql = "select [key] from [key] where [key] like ’" & key & "%’"
dim keyword
keyword = ""
set rs = conn.execute (sel_sql)
do while not rs.eof
keyword = keyword & rs(0) & "|"
rs.movenext
loop
response.Write(keyword)
end if
%>
[/code]
最后一个结果文件:index.html
[code=html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>google提示 </title>
<script src="xmlhttp.js" ></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<input name="txt_key" type="text" id="textarea" autocomplete="off" onkeyup="change_key()"/><br/>
<div id="search_suggest" ></div>
</form>
</body>
</html>
[/code]
分享:Asp读取文本文件并显示html head http-equiv=Content-Type content=text/html; charset=gb2312 title/title /head body % LANGUAGE = VBScript % % Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse
相关ASP教程:
- 相关链接:
- 教程说明:
ASP教程-ASP+AJAX做类似google的搜索提示(3)。