Tutorial 6: Creating Web Page Forms
Tutorial 6: Creating Web Page Forms
Country
form Send
SendRegistration
Registration Cancel
Cancel
button
XP
Form Control Elements
• Control elements :
– text boxes for text and numerical entries
– selection lists for long lists of options, usually appearing in a
drop-down list box
– radio buttons, also called option buttons, to select a single
option from a predefined list
– check boxes to specify an item as either present or absent
– groups boxes to organize form elements
– text areas for extended entries that can include several lines of
text
– buttons that can be clicked to start processing the form
• Each control element in which the user can enter information is called a
field.
XP
The <form> Tag
contact information
product information
usage information
comments
buttons
XP
Input Types
Type Description
type=”button” Display a button which can be clicked to
perform an action from a script
type=”checkbox” Display a check box
type=”file” Display a browse button to locate and select a
file
type=”hidden” Create a hidden field, not viewable on the form
type=”image” Display an inline image which can be clicked to
perform an action from a script
type=”password” Display a text box in which hides text entered
by the user
type=”radio” Display a radio (option) button
type=”reset” Display a button which resets the form when
clicked
type=”submit” Display a button which submits the form when
clicked
type=”text” Display a text box in which displays text
entered by the user
XP
Working with Text Boxes
no more than 5
characters are
allowed in this text
box
XP
Setting a Default Value for a Field
If customers from countries other than the United States use this Web form,
they can remove the default value by selecting the text and pressing the Delete key.
default value
XP
value of the id
attribute for the first
name field
XP
Using a Selection List
Your selection
list might look
slightly different
depending on the
browser and
browser version.
XP
Creating a Selection List
option
a single group label
option
group a single option
group
XP
Radio Buttons
In this sample code, the value sent to the CGI script does not match the field label.
If the user selects the Republican radio button, the value “gop”
is sent to the CGI script paired with the field name “party.”
XP
Creating a Group Box
<fieldset>
fields
</fieldset>
Where fields are the individual fields within a set.
default text
area text dimensions
of text area
The figure shows HTML tags for buttons that download a program,
retrieves information, and resets the form to its original values.
XP
Creating a File Button
– URL - the filename and location of the CGI script that process the form
– Method - how your Web browser sends data to the CGI script
– enctype - the format of the data stored in the form’s field
XP
Working with Form Attributes
This figure shows the CGI script that processes the form is located at the URL
http://www.langear.com/cgi/mailer (a fictional address) and uses the “post” method.
XP
Form Values
7 rows
XP
<form> tag needed after <body>