This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how google gives suggestions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how google gives suggestions?" Watch "how google gives suggestions?" New topic

how google gives suggestions?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Following is the line form source of google suggestions:

Here, I am not seeing any event (onKeyUp or onKeyPress) associated with this search textbox, then how suggestions are coming when we type something in it?

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
It is an autocomplete using the XMLHttpRequest Object (Ajax)

Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30138

It's probably being set in the JavaScript library. There is a technique I read about in PPK on JavaScript that favors this as it allows the HTML to be presentation only. The JavaScript sets itself up as the even handler for form elements. This makes sense for AJAX as you would want all the AJAX code to be in one place.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60810

Jeanne is correct. It is very common in Ajax applications to have JavaScript instrument the HTML DOM elements under script control rather than doing so in the HTML markup itself.

This allows for cleaner, modular code and is easier for the page author since the script handles all the nitty gritty details of setting up the elements correctly.
[ November 23, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jQuery in Action, 2nd edition
subject: how google gives suggestions?
Similar Threads
Good Link for JUnit Tests
Search engine related question
Testing center
Hospital management project in java