JS implementation of imitation Google, Baidu search box input information intelligent tips to achieve the method _javascript skills

Source: Internet
Author: User

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.

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.