JS implements the implementation of smart prompts like google and Baidu search box input information, jsgoogle

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.