User Guide
144 Developing Web Applications with ColdFusion
To populate a drop-down list box with query data using CFSELECT:
1. Open a new file in Studio.
2. Modify the file so that it appears as follows:
<CFQUERY NAME="getNames"
DATASOURCE="CompanyInfo">
SELECT * FROM Employees
</CFQUERY>
<CFFORM NAME="Form1" ACTION="submit.cfm"
METHOD="Post">
<CFSELECT NAME="employeeNames"
QUERY="getNames"
VALUE="Employee_ID"
DISPLAY="FirstName"
REQUIRED="yes"
MULTIPLE="yes"
SIZE="8">
</CFSELECT>
<BR><INPUT TYPE="Submit"
VALUE="Submit">
</CFFORM>
3. Save the file as selectbox.cfm and view it in your browser.
Note that because the MULTIPLE attribute is used, the user can select multiple entries
in the select box. Also, because the VALUE tag specifies the primary key for the
Employee table, this data is used in the form variable that is passed to the application
page specified in ACTION.
Embedding Java Applets
The CFAPPLET tag allows you to embed Java applets in a CFFORM. To use CFAPPLET,
you must first register your Java applet using the ColdFusion Administrator Applets
page. In the Administrator, you define the interface to the applet, encapsulating it so
that each invocation of the CFAPPLET tag is very simple.
CFAPPLET offers several advantages over using the HTML APPLET tag:
• Return values — Since CFAPPLET requires a form field name attribute, you can
avoid having to code additional JavaScript to capture the applet's return values.
You can reference return values like any other ColdFusion form variable:
form.variablename.
• Ease of use — Since the applet's interface is defined in the Administrator, each
instance of the CFAPPLET tag in your pages only needs to reference the applet's
name and specify a form variable name.