User Guide

Chapter 10: Building Dynamic Forms 131
<!--- Build the tree control --->
<CFFORM NAME="form1" ACTION="submit.cfm"
METHOD="Post">
<CFTREE NAME="tree1"
HSCROLL="no"
VSCROLL="no"
BORDER="yes"
HEIGHT="350"
REQUIRED="yes">
<CFTREEITEM VALUE="Department_ID, FullName"
QUERY="deptquery"
QUERYASROOT="Department_ID"
IMG="cd,folder">
</CFTREE>
<BR><INPUT TYPE="Submit" VALUE="Submit">
</CFFORM>
3. Save the page and view it in your browser.
Code Review
Note that the comma-separated items in the IMG and the VALUE attributes
correspond. If you leave out the IMG attribute, ColdFusion uses the folder image for all
levels in the tree.
CFTREE form variables
The CFTREE tag allows you to force a user to select an item from the tree control by
setting the REQUIRED attribute to YES. With or without the REQUIRED attribute,
ColdFusion passes two form variables to the application page specified in the CFTREE
ACTION attribute:
form.treename.node — Returns the node of the user selection.
Code Description
ORDER BY Department_ID
Order the query results by department.
<CFTREEITEM
VALUE="Department_ID, FullName"
Popluate the tree with the Department ID, and
under each department, the Full Name for each
employee in the department
QUERYASROOT="Department_ID"
Make the Department ID the root of the tree
IMG="cd,folder">
Use the ColdFusion-supplied images CD and
Folder.