The href
attribute in the cftreeitem
tag allows you to designate tree items as links. To use this feature in a cftree
, you simply define the destination of the link in the href
attribute of cftreeitem
. The URL for the link can be a relative URL or an absolute URL as in the following examples.
tree3.cfm
in ColdFusion Studio.
<cfform action="submit.cfm"> <cftree name="oak" highlighthref="Yes" height="100" width="200" hspace="100" vspace="6" hscroll="No" vscroll="No" border="No"> <cftreeitem value="Important Links"> <cftreeitem value="Macromedia Home" parent="Important Links" img="document" href="http://www.macromedia.com"> <cftreeitem value="ColdFusion Home" parent="Important Links" img="document" href="http://www.coldfusion.com"> </cftree> </cfform>
The following table describes the highlight code and its function:
When a user clicks on a tree item to link to a URL the cftreeItemKey
variable, which identifies the selected value, is appended to the URL in the form:
http://myserver.com?cftreeitemkey
=selected_value
Automatically passing the name of the selected tree item as part of the URL makes it easy to implement a basic "drill down" application that displays additional information based on the selection. For example, if the specified URL is another CFML page, it can access the selected value as the variable URL.cfteeitemkey
.
You can disable this behavior by setting the appendkey
attribute in the cftree
tag to No.