Wednesday, July 31, 2013

Handling the data Google sends you

What does the code look like in google.html? The text field where the user enters text is tied to a function named getSuggest by using the onkeyup event. As a result, getSuggest will be called every time the user types and releases a key. (Note that the event object is passed to getSuggest by this code, because that object holds information about which key was pressed, and also note the <div> element where the suggestions will appear,targetDiv.)

Here’s what the code looks like:

<body>
<H1>Google live search</H1>
Search for <input id = “textField” type = “text” name = “textField” onkeyup = “getSuggest(event)”>

<div id = “targetDiv”><div></div></div>
</body>