ASP+AJAX做類似google的搜索提示(3)_ASP教程

      編輯Tag賺U幣
      教程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

      共3頁上一頁123下一頁
      來源:模板無憂//所屬分類:ASP教程/更新時間:2010-03-26
      相關ASP教程