Multiple Select Lists - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 5: Making Variables Dynamic
The first example searched for department information based on a numeric primary
key field called "Department_ID." Suppose, instead, that the primary key is a database
field called "DepartmentName" that contains string values. In that case, it's necessary
to make the following modifications:
Make the value attribute of the checkboxes equal to the string value.
Enclose the value attribute in single quotes.
<INPUT TYPE="checkbox"
NAME="SelectedDepts"
VALUE="'Training'">
Training<BR>
<INPUT TYPE="checkbox"
NAME="SelectedDepts"
VALUE="'Marketing'">
Marketing<BR>
<INPUT TYPE="checkbox"
NAME="SelectedDepts"
VALUE="'HR'">
HR<BR>
<INPUT TYPE="checkbox"
NAME="SelectedDepts"
VALUE="'Sales'">
Sales<BR>
<INPUT TYPE="checkbox"
NAME="SelectedDepts_required"
VALUE="You must select at least one organization.">
If the user checked Marketing and Sales, the value of the SelectedDepts form field
would be 'Marketing','Sales'.
Note
SELECT *
FROM Departments
WHERE DepartmentName IN
(#PreserveSingleQuotes(form.SelectedDepts)#)
The statement sent to the database would be:
SELECT *
FROM Departments
WHERE DepartmentName IN ('Marketing','Sales')

Multiple select lists

ColdFusion treats multiple select lists (HTML input type SELECT with attribute
MULTIPLE) just like checkboxes. The data made available to your page from any
You must use the ColdFusion PreserveSingleQuotes function in the SQL
statement to prevent ColdFusion from escaping the single quotes in the
form field value:
49

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents