<!--- Insert film into database when form is submitted --->
<CFIF IsDefined("FORM.RatingID")>
  <CFQUERY DATASOURCE="ows">
    INSERT INTO Films(MovieTitle, RatingID, AmountBudgeted)
    VALUES ('#FORM.MovieTitle#', #FORM.RatingID#, #FORM.AmountBudgeted#)
  </CFQUERY>  
</CFIF>

<!--- Get list of ratings from database --->
<CFQUERY NAME="GetRatings" DATASOURCE="ows">
  SELECT RatingID, Rating
  FROM FilmsRatings
  ORDER BY RatingID
</CFQUERY>

<!--- Use query of queries feature to get highest and lowest rating ID --->
<CFQUERY NAME="GetMinMax" DBTYPE="query">
  SELECT MIN(RatingID) AS MinRating, MAX(RatingID) As MaxRating
  FROM GetRatings
</CFQUERY>

<HTML>
<HEAD><TITLE>Film Entry Form</TITLE></HEAD>
<BODY>
<H2>Film Entry Form</H2>

<!--- Data entry form --->
<CFFORM ACTION="#CGI.SCRIPT_NAME#" METHOD="POST">

  <!--- Slider control for selecting the film's rating --->
  <CFSLIDER
    NAME="RatingID"
    VALUE="2"
    LABEL="Rating: %value%"
    RANGE="#GetMinMax.MinRating#,#GetMinMax.MaxRating#"
    TICKMARKMAJOR="Yes"
    TICKMARKLABELS="#ValueList(GetRatings.Rating)#"
    VERTICAL="Yes"
    WIDTH="160"
    HEIGHT="200"
    LOOKANDFEEL="Metal"
    ALIGN="LEFT"
    HSPACE="5">

  <!--- Text entry field for expense description --->
  <P><B>New Film Title:</B><BR>
  <CFINPUT NAME="MovieTitle" SIZE="50" MAXLENGTH="50"
    REQUIRED="Yes" MESSAGE="Please don't leave the film title blank."><BR>
  
  <!--- Text entry field for expense description --->
  <P><B>Short Description / One-Liner:</B><BR>
  <CFINPUT NAME="PitchText" SIZE="50" MAXLENGTH="50"
    REQUIRED="Yes" MESSAGE="Please don't leave the one-liner blank."><BR>
  
  <!--- Text entry field for expense description --->
  <P><B>New Film Budget:</B><BR>
  <CFINPUT NAME="AmountBudgeted" SIZE="15" 
    REQUIRED="Yes" MESSAGE="Please don't leave the film title blank."
    VALIDATE="float"><BR>
    
  

  <!--- Submit button for form --->
  <P><INPUT TYPE="Submit" VALUE="Submit New Film">
</CFFORM>  

</BODY>
</HTML>
