Chapter 24. Select, Option, and FileUpload Objects
IN THIS CHAPTER
Triggering action based on a user's selection in a pop-up or select list
Modifying the contents of select objects
Using the fileUpload object
Selection lists—whether in the form of pop-up menus or scrolling lists—are space-saving form elements in HTML pages. They enable designers to present a lot of information in a comparatively small space. At the same time, users are familiar with the interface elements from working in their own operating systems' preference dialog boxes and application windows.
However, selection lists are more difficult to script, especially in older browsers, because the objects themselves are complicated entities. Scripts find all the real data associated with the form control in option
elements that are nested inside select
elements. As you can see throughout this chapter, backward-compatible references necessary to extract information from a select
element object and its option
objects can get pretty long. On the upside, the most painful backward compatibility efforts are all but unnecessary given the proliferation of modern browsers.
The other object covered in this chapter, the fileUpload
input object, is frequently misunderstood as being more powerful than it actually is. It is, alas, not the great file transfer elixir desired by many page authors.
select Element Object
For HTML element properties, methods, and event handlers, see Chapter 15.
Properties | Methods | Event Handlers |
---|---|---|
†See "Text Input Object" ... |
Get JavaScript® Bible, Sixth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.