This article is an example of the implementation of JS to achieve imitation Google, Baidu search box input information intelligent tips. Share to everyone for your reference. as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Server-side C # code
<%@ WebHandler language= "C #" class= "SearchResult"%> using System;
Using System.Web;
Using System.Data; public class Searchresult:ihttphandler {public void ProcessRequest (HttpContext context) {object Queryword=context.
request.querystring["SearchText"]; if (Queryword!= null) {if (queryword.tostring). Trim ().
Length > 0) {DataTable dt = Getdb ();
String returntext = ""; if (dt!= null && dt. Rows.Count > 0) {datarow[] dr = dt. Select ("name like '%" + queryword.)
ToString () + "% '"); if (Dr. Length > 0) {for (int i = 0; i < Dr.) Length; i++) {//can be set to return multiple strings returntext + = dr[i]["id"]. ToString () + "@" + dr[i]["name"].
ToString () + "\ n"; }} context.
Response.Write (Returntext); Context.
Response.End ();
}} public bool IsReusable {get {return false; ///<summary>///How to obtain a data source///</summary>///<returns> data source </returns> PrivaTe DataTable Getdb () {DataTable dt = new DataTable (); Dt.
Columns.Add ("id"); Dt.
Columns.Add ("name"); Dt.
Columns.Add ("Age"); Dt.
Rows.Add (new object[] {"000001", "John", "26"}); Dt.
Rows.Add (new object[] {"000002", "Zhangxiao", "26"}); Dt.
Rows.Add (new object[] {"000003", "Zhang Yi", "27"}); Dt.
Rows.Add (new object[] {"000004", "Dick", "25"}); Dt.
Rows.Add (new object[] {"000005", "Li Shing", "27"});
return DT; }
}
The
wants this article to help you with your JavaScript programming.