Using forms to specify the data to retrieve
563
Reviewing the code
The following table describes the highlighted code and its function:
Form notes and considerations
When using forms, keep the following guidelines in mind:
•
To make the coding process easy to follow, name form controls the same as target database
fields.
•
For ease of use, limit radio buttons to between three and five mutually exclusive options. If you
need more options, consider a drop-down list.
•
Use list boxes to allow the user to choose from many options or to chose multiple items from a
list.
•
All the data that you collect on a form is automatically passed as form variables to the
associated action page.
Code
Description
<form action="actionpage.cfm"
method="post">
Gathers the information from this form using the
Post method, and do something with it on the page
actionpage.cfm.
<input type="Text" name="FirstName"
size="20" maxlength="35">
Creates a text box called FirstName where users can
enter their first name. Makes it 20 characters wide,
but allows input of up to 35 characters.
<input type="Text" name="LastName"
size="20" maxlength="35">
Creates a text box called LastName where users can
enter their first name. Makes it 20 characters wide,
but allows input of up to 35 characters.
<input type="Text" name="Salary"
size="10" maxlength="10">
Creates a text box called Salary where users can
enter a salary to look for. Makes it 10 characters
wide, and allows input of up to 10 characters.
<select name="City">
<option value="Arlington">
Arlington
<option value="Boston">Boston
<option value="Cambridge">
Cambridge
<option value="Minneapolis">
Minneapolis
<option value="Seattle">Seattle
</select>
Creates a drop-down list box named City and
populate it with the values “Arlington,” “Boston,”
“Cambridge,” “Minneapolis,” and “Seattle.”
<input type="checkbox" name=
"Contractor" value="Yes" checked>Yes
Creates a check box that allows users to specify
whether they want to list employees who are
contractors. Box selected by default.
<input type="Reset"
name="ResetForm"
value="Clear Form">
Creates a reset button to allow users to clear the
form. Puts the text Clear Form on the button.
<input type="Submit"
name="SubmitForm"
value="Submit">
Creates a submit button to send the values that users
enter to the action page for processing. Puts the text
Submit on the button.
Summary of Contents for ColdFusion MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......