Embedding URLs in a CFTREE

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.

Note To embed links in a CFTREE:
  1. Open a new file named tree3.cfm in Studio.
  2. Modify the page so that it appears as follows:
    <CFFORM ACTION="submit.cfm">
    
        <CFTREE NAME="oak"
            HIGHLIGHTHREF="yes"
            HEIGHT="100"
            WIDTH="200"
            HSPACE="100"
            VSPACE="6"
            HSCROLL="no"
            VSCROLL="no"
            BORDER="no"
            DELIMITER="?">
    
            <CFTREEITEM VALUE="Important Links">
            <CFTREEITEM VALUE="Allaire Home"
                PARENT="Important Links"
                IMG="document"
    HREF="http://www.allaire.com">
            <CFTREEITEM VALUE="Allaire Forums"
                PARENT="Important Links"
                IMG="document"
    HREF="http://forums.allaire.com">
        </CFTREE>
    </CFFORM>
    
  3. Save the page and view it in your browser.

Code Review
Code Description
HREF="http://www.allaire.com">
Make the node of the tree a link.
HREF="http://forums.allaire.com"
Make the node of the tree a link. Note HREF can refer to the name of a column in a query if the tree item is populated from that query.

Specifying which tree items to send to the action page

When a user selects a tree item and submits the form, the CFTREEITEMKEY variable is appended to the URL passed to the application page specified in the CFFORM ACTION attribute, in the form:

http://myserver.com?CFTREEITEMKEY=selected_value

You can disable this key by setting the APPENDKEY attribute in the CFTREE tag to No.