<!--- If the form is being submitted --->
<CFIF IsDefined("FORM.Description")>
  <!--- Database insersion code would go here. The chosen expense --->
  <!--- category from tree would be available as #FORM.ExpenseCat.node# --->
</CFIF>

<!--- Construct connection string so we can query ExpCats.txt file --->
<CFSET Driver = "{MERANT 3.70 ColdFusion OEM 32-BIT TextFile (*.*)}">
<CFSET DBDir  = GetDirectoryFromPath(GetCurrentTemplatePath())>
<CFSET ConStr = "DRIVER=#Driver#;DB=#DBDir#;FLN=1;tT=COMMA;UT=GUESS">

<!--- Query ExpCats.txt file for list of expense categories --->
<CFQUERY DBTYPE="dynamic" CONNECTSTRING="#ConStr#" NAME="GetCats">
  SELECT * FROM ExpenseCats.txt
  ORDER BY ParentCatID, Description
</CFQUERY>

<!--- Query Films.txt file for list of films --->
<CFQUERY NAME="GetFilms" DATASOURCE="ows">
  SELECT * FROM Films
  ORDER BY MovieTitle
</CFQUERY>

<HTML>
<HEAD><TITLE>Expense Entry Form</TITLE></HEAD>
<BODY>

<!--- Tree controls must appear between <CFFORM> tags --->
<CFFORM ACTION="#CGI.SCRIPT_NAME#" METHOD="POST">

  <!--- Tree control --->
  <B>Expense Category:</B><BR>
  <CFTREE
    NAME="ExpenseCat"
    WIDTH="200"
    HEIGHT="300"
    BORDER="Yes"
    COMPLETEPATH="Yes" 
    REQUIRED="Yes"
    MESSAGE="Please pick a category from the tree."
    ALIGN="LEFT">

    <!--- For each category, generate a tree item --->
    <CFLOOP QUERY="GetCats">
      <CFTREEITEM
        PARENT="#GetCats.ParentCatID#" 
        VALUE="#GetCats.CatID#"
        DISPLAY="#GetCats.Description#"
        IMG="folder">
    </CFLOOP>
  </CFTREE>
  
  <!--- Drop-down list of films --->
  <B>Film:</B><BR>
  <CFSELECT
    NAME="FilmID"
    QUERY="GetFilms"
    VALUE="FilmID"
    DISPLAY="MovieTitle"
    MESSAGE="Please choose a Film first."/><BR>
  
  <!--- Text entry field for expense description --->
  <P><B>Expense Description:</B><BR>
  <CFINPUT NAME="Description" SIZE="50" MAXLENGTH="200"
    REQUIRED="Yes" MESSAGE="Please don't leave the Description blank."><BR>
  
  <!--- Text entry field for expense amount --->
  <P><B>Expense Amount:</B><BR>
  <CFINPUT NAME="ExpenseAmount" SIZE="10" MAXLENGTH="200"
    REQUIRED="Yes" VALIDATE="float" 
    MESSAGE="You must fill in an amount first."><BR>
  
  <!--- Submit button for form --->
  <P><INPUT TYPE="Submit" VALUE="Submit New Expense">
</CFFORM>  

</BODY>
</HTML>
