User Guide
312 Chapter 2: ColdFusion Tags
cfselect
Description
Constructs a drop-down list box form control. Used within a cfform tag.
You can populate the list from a query, or by using the HTML
option tag.
Category
Forms tags
Syntax
<cfselect
name = "name"
required = "Yes" or "No"
message = "text"
onError = "text"
size = "integer"
multiple = "Yes" or "No"
query = "queryname"
selected = "column_value"
value = "text"
display = "text"
passThrough = "HTML_attributes">
</cfselect>
See also
cfapplet, cfform, cfgrid, cfinput, cfgridcolumn, cfgridrow, cfgridupdate,
cfslider, cftextinput, cftree, cftreeitem
Attributes
Attribute Req/Opt Default Description
name Required Name of the select form element
size Optional 1 Number of entries to display at one time. The default, 1,
displays a drop-down list. Any other value displays a list box
with
size number of entries visible at one time.
required Optional No • Yes: a list element must be selected when form is submitted.
Note: This attribute has no effect if you omit the
size attribute
or set it to 1 because the browser always submits the displayed
item.
• No
message Optional Message to display if
required = "Yes" and no selection is
made.
onError Optional Custom JavaScript function to execute if validation fails
multiple Optional No • Yes: allow selecting multiple elements in drop-down list
• No
query Optional Name of query to populate drop-down list.
selected Optional A list of option values to preselect in the selection list. This
attribute applies only if list items are generated from a query.
The
cfform preservedata attribute value can override this
value.