Creating Dynamic Check Boxes and Multiple-Selection List Boxes
The user sees the name of the department, but the
is a number that corresponds to the underlying database primary key for the
department's record.
If the user checks the Marketing and Sales items, the value of the SelectedDept form
field is "2,4" and you use the SelectedDepts in the following SQL statement:
SELECT *
The ColdFusion Server sends the following statement to the database:
SELECT *
Searching string values
To search for a database field containing string values (instead of numeric), you must
modify the
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 this:
<input type="checkbox"
<input type="checkbox"
<input type="checkbox"
<input type="checkbox"
If the user checked Marketing and Sales, the value of the SelectedDepts form field
would be the list Marketing,Sales.
SELECT *
FROM Departmt
WHERE Dept_ID IN ( #Form.SelectedDepts# )
FROM Departmt
WHERE Dept_ID IN ( 2,4 )
and
checkbox
name="SelectedDepts"
value="Training">
Training<br>
name="SelectedDepts"
value="Marketing">
Marketing<br>
name="SelectedDepts"
value="HR">
HR<br>
name="SelectedDepts"
value="Sales">
Sales<br>
FROM Departmt
WHERE Dept_Name IN
(#ListQualify(Form.SelectedDepts,"'")#)
syntax.
cfquery
attribute of each check box
value
85
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?