title: Dynamic Dependent / Triple Related selects in ColdFusion, third not holding first select
body: <p>First of all I’m not only brand new to SO, but I’m also brand new to any kind of web programming, so total newb, thanks for your help and patience! So, zero previous experience with HTML, ColdFusion, SQL, SQL Server,  etc, so anything I’ve picked up I’ve learned in the past 2 weeks. </p>
  
  <p>I am trying to make 3 dynamic dependent dropdown menus (triple related selects) in ColdFusion, that ultimately end up opening a map in another .CFM page. The dropdowns are populated from one single table in SQL Server.
  I’ve done a lot of research (here on SO and elsewhere) and I have a method that is mostly working, but it has an issue and I would love help in figuring out why one thing isn’t working.  I am using a .CFC to query the database for the info for each dropdown menu and I’m trying to make each dependent on the previous, and then in the .CFM I’m using “bind”.  Here's my code for both the CFC and CFM:</p>
  
  <p>CFC (named GettingData):</p>
  
  <pre><code>&lt;cfcomponent displayname="GetStuff" hint="Getting data on cruises from database"&gt;
     &lt;!---GET ARRAY OF TRIBUTARIES---&gt;
     &lt;cffunction name="getData" access="remote"  returntype="query" hint="Get data for first select"&gt;
        &lt;!---define variables---&gt;
        &lt;cfset var data="tributary"&gt;
        &lt;!---Run the query for tributaries---&gt;
        &lt;cfquery name="data" datasource="mydatasource"&gt;
           SELECT distinct Tributary
           FROM df_cruises
           ORDER BY Tributary
        &lt;/cfquery&gt;
        &lt;!---and return it---&gt;
        &lt;cfreturn data&gt;
     &lt;/cffunction&gt;
     &lt;!---Get DATES by tributary---&gt;
     &lt;cffunction name="getDates" access="remote" returntype="query" 
        hint="Get cruise dates by tributary for select dropdown"&gt;
        &lt;cfargument name="Tributary" type="any" required="no"&gt;
        &lt;!---Define variables---&gt;
        &lt;cfset var data="CruiseDate"&gt;
        &lt;!---Run query to get Date Data---&gt;
        &lt;cfquery name="data" datasource="mydatasource"&gt;
           SELECT *, CruiseDate AS date &lt;!---this gets date to display correctly in dropdown---&gt;
           FROM df_cruises
           WHERE Tributary='#ARGUMENTS.Tributary#'&lt;!---single quotes for SQL Server---&gt;
           ORDER BY CruiseDate desc
        &lt;/cfquery&gt;
        &lt;!---And return it---&gt;
        &lt;cfreturn data&gt;
     &lt;/cffunction&gt;
     &lt;!---getting the html file based on the cruisedate selection---&gt;
     &lt;cffunction name="getmapname" access="remote" returntype="query" 
        hint="Get html file by tributary and cruisedate for dropdown select"&gt;
        &lt;cfargument name="Tributary" type="any" required="no"&gt;
        &lt;cfargument name="mapfile" type="any" required="no"&gt;
        &lt;!---Define variables---&gt;
        &lt;cfset var data=""&gt;
        &lt;cfset var data=""&gt;
        &lt;!---Get file html Data---&gt;
        &lt;cfquery name="data" datasource="mydatasource"&gt;
           SELECT CruiseDate, Tributary, File_html
           FROM df_cruises
           WHERE CruiseDate='#ARGUMENTS.mapfile#'AND Tributary='#ARGUMENTS.Tributary#'AND File_html&lt;&gt;'notsampled'
        &lt;/cfquery&gt;
        &lt;!---And return it---&gt;
        &lt;cfreturn data&gt;
     &lt;/cffunction&gt;
  &lt;/cfcomponent&gt;
  </code></pre>
  
  <p>CFM (named DropdownDisplay):</p>
  
  <pre><code>&lt;cfparam name="url.File_html" default = '2'&gt;
  &lt;cfform name="CruiseChoose" action="mapdisplayv3.cfm" method="post"&gt;
     &lt;table align="center" bgcolor="orange"&gt;
        &lt;tr&gt;
           &lt;th colspan="2"&gt;
              &lt;font size="+1"&gt;First Select a Water Body, Then Choose Cruise Date&lt;/font&gt;
           &lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
           &lt;td&gt;
              &lt;br/&gt;
              Tributary/Water Body:&lt;br /&gt;
              &lt;cfselect name="Tributary" 
                 bind="cfc:GettingData.getData()"
                 display="Tributary"
                 value="Tributary"
                 bindonload="true"
                 multiple="no"
                 size="6" /&gt;
           &lt;/td&gt;
           &lt;td&gt;
              &lt;br /&gt;
              Cruise Dates:&lt;br /&gt;
              &lt;cfselect name="CruiseDate"
                 bind="cfc:GettingData.getDates({Tributary})"
                 bindonload="false"
                 type="link"
                 display="date"
                 value="CruiseDate"
                 multiple="no"
                 size="6"/&gt;
           &lt;/td&gt;
           &lt;td&gt;
              &lt;br&gt;
              Map Links:&lt;br /&gt;
              &lt;cfselect name="link"
                 bind="cfc:GettingData.getmapname({CruiseDate},{Tributary})"
                 bindonload="false"
                 type="any"
                 display="File_html"
                 value="File_html"
                 multiple="no"
                 size="3"/&gt;
           &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
           &lt;td colspan="2" align="center"&gt;
              &lt;br /&gt;
              &lt;/form&gt;
              &lt;!--- submit button ---&gt; 
              &lt;cfoutput&gt;  &lt;input type="submit" name="submit" value="View Selected Maps" alt="View Map Selection Button"&gt;&lt;br&gt;&lt;/cfoutput&gt;
              &lt;!--- Reset button. ---&gt; 
              &lt;input name="reset" type="reset" value="Clear Selections" alt="Clear Selections Button"&gt;
           &lt;/td&gt;
        &lt;/tr&gt;
     &lt;/table&gt;
  &lt;/cfform&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The first dropdown is pulling a list of tributaries, and when a ‘Tributary’ is chosen the second dropdown correctly populates the list of ‘CruiseDates’ when they were sampled.  The third dropdown is supposed to populate with the ‘File_html’ from the table which becomes a link to open an image map of data on another CFM. (This isn’t my ultimate goal, this was me baby-stepping my way there.)  </p>
  
  <p>The issue I am having is that the third dropdown does not seem to be holding the dependency to the first dropdown selection (Tributary), so when a CruiseDate is selected where 2 tributaries happened to be sampled on the same date both of those File_html names show up in the third dropdown (screenshot):
  In the CFC, in “getmapname” function, I’ve tried using 2 arguments (which I saw used somewhere online) so that I can reuse the argument  (along with the cfargument name="mapfile") so that in the last query I can do the following:</p>
  
  <pre><code>&lt;cfquery name="data" datasource="mydatasource"&gt;
      SELECT CruiseDate, Tributary, File_html
      FROM df_cruises
      WHERE CruiseDate='#ARGUMENTS.mapfile#' AND Tributary='#ARGUMENTS.Tributary#'
      AND File_html&lt;&gt;'notsampled'
  &lt;/cfquery&gt;
  </code></pre>
  
  <p>This didn’t work. I get errors when I have 2 arguments, it only seems to allow 1. </p>
  
  <p>Here's a screenshot of the third dropdown showing that, although 'Back River' is selected, it's pulling the File_html for 2 tributaries that were sampled on the same date: 
  <a href="https://i.stack.imgur.com/vSqvZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vSqvZ.jpg" alt="screenshot of 3rd dropdown not holding 1st dropdown select"></a></p>
  
  <p>I also started working on a javascript version but I’m stuck on that as well, and since this was so close I keep working on this method.  However, if it’s impossible to do triple related selects with this method I’ll have to move on!</p>
  
  <p>Any help would be really wonderful, thank you! -B
  (sorry for the long post, just trying to be thorough)</p>