Приглашаем посетить
Forms and Intrinsic Controls
Chapter 10
Forms and Intrinsic Controls
This chapter shows you how to script user interfaces that request and
process input from the user. HTML supports both controls that can take user
input and an element that provides a form model for grouping contents and
submitting them back to the server. These controls are known as
intrinsic controls because they are built into HTML. The functionality of the intrinsic
controls is still fairly limited when compared to most forms and database
packages. Validation and formatting are not yet directly supported, but you can
easily add this behavior using the object model. This chapter presents techniques
for manipulating forms and intrinsic controls within a document; it presents
the intrinsic controls in functional categories and shows you how to extend
HTML forms to be on a par with powerful forms packages.
The following topics are covered in this chapter:
- HTML
forms Forms are used to group related input from the
user and submit it back to the server. Forms are fully accessible to
scripts and thus can also be used for client-side processing. This
section provides an introduction to HTML forms and Input elements.
- Programming text Input
elements Text Input elements create a text box for requesting information from the user. Four types of
text boxes are defined by HTML: a single-line text box, a
multiple-line text box, a password text box, and a filename text box. This
section focuses on techniques for using events and the object model to
validate and format the user's input.
- Programming Select (list)
elements Select elements are used to provide the user with a defined list of options. Two styles of lists
can be created using intrinsic controls: list boxes and combo boxes.
For both styles of lists, the programming model is the same. This
section focuses on techniques for scripting lists and for dynamically
adding and removing list items.
- Programming lists using radio buttons and check
boxes An alternative way to allow the user to select from a list of elements is
to provide a set of check boxes or radio buttons. Check boxes are useful for simple yes/no questions; radio buttons are used for
selecting a single item from a list. This section discusses the benefits
of using lists with buttons vs. using a list box style and provides scripting
techniques.
- Programming command button
elements Four types of command buttons can be created in HTML: plain-text buttons, rich
HTML buttons, submit buttons, and reset buttons. Submit and reset
buttons have a defined behavior when used in forms and also act as
the Default and Cancel buttons. The Default button is indicated by
an extra border and is the button that receives the click event
when the user presses Enter; the Cancel button is clicked when the
user presses Esc. The other types of command buttons' behavior must
be defined through a script. This section shows you how to take
advantage of command buttons.
- Programming Label and Fieldset
elements Labels and fieldsets are a new addition to HTML and are necessary to create rich
forms. The Label element is used to define the relationship between
the Input element and some contents, and the Fieldset element is
used to define the relationship among groups of controls.
[Содержание]