User Guide
Chapter 10: Building Dynamic Forms 129
Code Review
See the following Web site for information on JavaScript validation scripts:
• http://www.dannyg.com/javascript
Building Tree Controls with CFTREE
The CFTREE form lets you display hierarchical information in a space-saving
collapsible tree populated from data source queries. To build a tree control with
CFTREE, you use individual CFTREEITEM tags to populate the control. You can specify
one of six built-in icons to represent individual items in the tree control.
To create and populate a tree control from a query:
1. Open a new file named tree1.cfm in Studio.
2. Modify the page so that it appears as follows:
<CFQUERY NAME="engquery" DATASOURCE="CompanyInfo">
SELECT FirstName + ’ ’ + LastName AS FullName
FROM EMPLOYEES
</CFQUERY>
<CFFORM NAME="form1" ACTION="submit.cfm"
METHOD="Post">
4 <CFTREE NAME="tree1"
4 REQUIRED="yes"
4 HSCROLL="no"
4 VSCROLL="yes">
4 <CFTREEITEM VALUE=FullName
Code Description
<SCRIPT>
<!--
function testbox(form) {
Ctrl = form.inputbox1;
if (Ctrl.value == "" || Ctrl.value.indexOf
(’@’, 0) == -1) {
return (false);
} else
return (true);
}
//-->
</SCRIPT>
JavaScript code to test for
valid entry in text box.
ONVALIDATE="testbox"
Text box control
parameter that calls the
JavaScript test.