HTML Forms
HTML Forms
INTERACTIONS:
FORMS
Form Processing
HTML
Form
B Data from
Input
r Form
Data from Form
o Form Web
User Processing
w Server Program
s (CGI)
HTML
Output e Document Data
HTML Flow
r
Document
Database
Management
System
</Form>
Forms
• Form Input: INPUT
– Only used within a FORM element and is denoted by
<INPUT>.
– Attributes:
• NAME: The name of the particular element.
• MAXLENGTH: The maximum number of characters that can be
entered by users in a text field.
• SIZE: Specifies the size of the field and depends on its type.
• SRC: Denote URL for an image.
• VALUE: Contain the initial value displayed to users.
• TYPE: Defines the type of data used in the field.
• CHECKED: Indicates that a checkbox or radio button is selected.
• DISABLED: Prevents the field from receiving focus.
• ALIGN: Alignment if image is used.
• READONLY: Prevents modification of the contents of the field.
TYPE Attribute
• Checkbox:
– An object where several values can be selected at
the same time.
– The checkbox is submitted as separate
name/value pair for each selected value.
– Checkbox that are grouped together should have
• a different name.
• a unique value.
TYPE Attribute
• Checkbox:
<FORM>
What pets do you own?
<P><INPUT TYPE=CHECKBOX name = petdog
value=“dog”> DOG
<BR><INPUT TYPE=CHECKBOX name = petcat
value=“cat”> CAT
<BR><INPUT TYPE=CHECKBOX name = petbird
value=“bird”> BIRD
<BR><INPUT TYPE=CHECKBOX name = petfish
value=“fish”> FISH
</FORM>
TYPE Attribute
• Radio Boxes:
– An object that defines an item where only one
value can be selected from a set of possibilities.
– A set is defined as the group of radio boxes with
the same NAME attribute.
– Never set more than one radio box at a time with
the CHECKED attribute.
<P><B>Charge Card:</B>
<INPUT NAME = “cc” VALUE=“visa” TYPE = “radio”>VISA
<INPUT NAME = “cc” VALUE=“mc” TYPE = “radio”>Master Card
<INPUT NAME = “cc” VALUE=“amex” TYPE = “radio”>American
Express
TYPE Attribute
• HIDDEN Type:
– When this type is chosen, no field is presented to
the user.
– Primary use is record keeping for programs that
may parse user input from forms.
– May be used for shopping carts.
TYPE Attribute
• TEXT type:
– Specifies a single line text entry field.
– Can be used with the MAXLENGTH and SIZE
attributes (MAXLENGTH >= SIZE)
<FORM><P><INPUT TYPE=“button”
VALUE=“Back to Last Document”
onClick=“history.back( )”></P></FORM>
TEXTAREA
• Let users enter more than one line of text.
• Uses attributes ROWS and COLS to size.
• WRAP Attribute:
– OFF: No wrapping
– VIRTUAL: Display wraps but long lines are sent
as one line.
– PHYSICAL: Word wraps and text is sent with
wrap points.
PullDown Menu
• Use SELECT and OPTION to create
pulldown menu.
• SELECT:
– Allows the user to choose one (or possibly more)
items from a list.
– Attributes: MULTIPLE, SIZE, and NAME.
• OPTION:
– Specifies the list items.
– Attributes: SELECTED, VALUE, and LABEL
PullDown Menu
• Example:
name=bob&phone=555-1212
– No URL is sent.