
722
DEVELOPING
COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Las
t
upda
te
d 8/5/2010
Select one or departments to get more information on:
<cfselect name="SelectDepts" multiple>
<option value="1">Training
<option value="2">Marketing
<option value="3">HR
<option value="4">Sales
</cfselect>
If the user selects the Marketing and Sales items, the value of the SelectDepts form field is 2,4. If this parameter is used
in the following SQL statement:
SELECT *
FROM Departmt
WHERE Dept_ID IN (#form.SelectDepts#)
The following statement is sent to the database:
SELECT *
FROM Departmt
WHERE Dept_ID IN (2,4)
Handling string values
Suppose you want the user to select departments from a multiple-selection list box. The database search field is a string
field. The query retrieves detailed information on the selected departments, as follows:
<cfselect name="SelectDepts" multiple>
<option value="Training">Training
<option value="Marketing">Marketing
<option value="HR">HR
<option value="Sales">Sales
</cfselect>
If the user selects the Marketing and Sales items, the SelectDepts form field value is Marketing,Sales.
Just as you did when using check boxes to search database fields containing string values, use the ColdFusion
ListQualify
function with multiple-selection list boxes:
SELECT *
FROM Departmt
WHERE Dept_Name IN (#ListQualify(Form.SelectDepts,"'")#)
The following statement is sent to the database:
SELECT *
FROM Departmt
WHERE Dept_Name IN ('Marketing','Sales')
Building Dynamic Forms with cfform Tags
You can use the
cfform
tag to create rich, dynamic forms with sophisticated graphical controls, including several Java
applet or Flash controls. You can use these controls without writing a line of Java or Flash code.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...