Building Drop-Down List Boxes - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

166

Building Drop-Down List Boxes

The drop-down list box that you can create with
select
error handling, and, most importantly, allows you to automatically populate the
selection list from a query.
When you populate a
name of the query that is supplying data for the
name for each list element that you want to display.
To populate a drop-down list box with query data using cfselect:
1
2
3
Note that because the tag includes the
multiple entries in the list box. Also, because the
primary key for the Employee table, Employee IDs (not first names) get passed in the
Form.Employee variable to the application page specified in the
attribute.
tag. However,
cfselect
cfselect
Open a new file in ColdFusion Studio.
Modify the file so that it appears as follows:
<cfquery name="getNames"
datasource="CompanyInfo">
SELECT * FROM Employee
</cfquery>
<cfform name="Form1" action="submit.cfm"
method="Post">
<cfselect name="employees"
query="getNames"
value="Emp_ID"
display="FirstName"
required="Yes"
multiple="Yes"
size="8">
</cfselect>
<br><input type="Submit"
value="Submit">
</cfform>
Save the file as
selectbox.cfm
Chapter 9 Building Dynamic Forms
cfselect
gives you more control over user inputs, provides
with data from a query, you only need to specify the
cfselect
and view it in your browser.
attribute, the user can select
multiple
value
is similar to the HTML
and the query column
tag specifies Emp_ID, the
cfform action

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents