JS implements the implementation of smart prompts like google and Baidu search box input information, jsgoogle
This article describes how to implement smart prompts in the search box of google and Baidu using JavaScript. Share it with you for your reference. The details are as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Server 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 ++) {// multiple strings can be returned. returnText + = dr [I] ["id"]. toString () + "@" + dr [I] ["name"]. toString () + "\ n" ;}} context. response. write (returnText); context. response. end () ;}} public bool IsReusable {get {return false ;}} /// <summary> /// method for obtaining the 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", "Zhang San", "26"}); dt. rows. add (new object [] {"000002", "Zhang Xiao", "26"}); dt. rows. add (new object [] {"000003", "Zhang Lan", "27"}); dt. rows. add (new object [] {"000004", "Li Si", "25"}); dt. rows. add (new object [] {"000005", "Li Xing", "27"}); return dt ;}}
I hope this article will help you design javascript programs.