When you start typing in the textbox, a JavaScript sends the letters off to a server and the server returns a list of suggestions. It consists of three pages:
ShowHint.js
, and
GetHint.php
.
<html> <head><script src="ShowHint.js"></script></head> <body> <form action=""> Course: <input type="text" id="txt1" onKeyUp="showHint( this.value )" /> Suggestions: <span id="txtHint"></span> </form> </body> </html> |
txt1
.
The form works like this:
onKeyup
executes JavaScript code when a Keyup
event occurs; that is, when the user releases a key.
showHint
is executed.
<span>
called txtHint
.
This is used as a placeholder for the return data of the showHint
function.
A guy goes ice fishing for the very first time. All of a sudden, he hears a voice. “There are no fish under the ice!” He ignores it and moves to another area, cuts a hole, and tosses his line in. Again, he hears the booming voice: “There are no fish under the ice!” He nervously looks up and asks, “Lord? Is that you?” “No, this is the rink manager!” — Emmy Award-winning actress Allison Janney |