However, because there??™s a significant likelihood the user is
going to specify one of a set number of values, you want to facilitate the user??™s input
by using auto-completion. Auto-completion works by monitoring what the user begins
to type into the input box and suggesting a value based on what??™s been entered so far.
For instance, suppose you??™re building a fantasy football Web site and want to collect
information about each user??™s favorite football team. While one could presume most
will choose an NFL or collegiate team, some of the younger players might opt to enter
their favorite high school team. While it??™s fairly trivial to compile a list of NFL teams
and at least the well-known collegiate teams, creating a similar list of the thousands
of high school teams around the country would be difficult at best. Therefore, you use
a text input box with auto-completion enabled. Should the user begin entering Steel,
the auto-complete mechanism will offer up the first matching array element, which
is Steelers, as shown in Figure 13-2.
Figure 13-2. Using auto-completion
However, if the user continues typing, changing the string to Steel (with a concluding
space), auto-completion will present Steel Curtains, as shown in Figure 13-3.
Figure 13-3. Auto-completion adapting to alternative choices
The code used to implement this feature follows:
require 'HTML/QuickForm.
Pages:
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440