Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 726

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
The first example searched for department information based on a numeric primary key field called Dept_ID.
Suppose, instead, that the primary key is a database field called Dept_Name that contains string values. In that case,
your code for check boxes should look like the following:
<cfinput type="checkbox"
name="SelectedDepts"
value="Training">
Training<br>
<cfinput type="checkbox"
name="SelectedDepts"
value="Marketing">
Marketing<br>
<cfinput type="checkbox"
name="SelectedDepts"
value="HR">
HR<br>
<cfinput type="checkbox"
name="SelectedDepts"
value="Sales">
Sales<br>
If the user checked Marketing and Sales, the value of the SelectedDepts form field would be the list Marketing,Sales
and you use the following SQL statement:
SELECT *
FROM Departmt
WHERE Dept_Name IN
(#ListQualify(Form.SelectedDepts,"'")#)
In SQL, all strings must be surrounded in single-quotation marks. The
specified qualifying character (here, a single-quotation mark) around each item in the list.
If you select the second and fourth check boxes in the form, the following statement gets sent to the database:
SELECT *
FROM Departmt
WHERE Dept_Name IN ('Marketing','Sales')
Multiple selection lists
A multiple-selection list box is defined by a
and a
attribute value greater than 1. ColdFusion treats the result when a user selects multiple choices from a
size
multiple-selection list box like the results of selecting multiple check boxes. The data made available to your page from
any multiple-selection list box is a comma-delimited list of the entries selected by the user; for example, a list box could
contain the four entries: Training, Marketing, HR, and Sales. If the user selects Marketing and Sales, the form field
variable value is Marketing, Sales.
You can use multiple-selection lists to search a database in the same way that you use check boxes.
Handling numeric values
Suppose you want the user to select departments from a multiple-selection list box. The query retrieves detailed
information on the selected departments, as follows:
ListQualify
or
tag with a
select
cfselect
Last updated 1/20/2012
function returns a list with the
or
multiple
multipe="yes"
721
attribute

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents