1 Reply Latest reply on Nov 28, 2012 9:39 AM by AaronMRenfroe

    Array problem - Related Selects


      Good Morning,


      I'm a newbie when it comes to this so I apologize ahead of time.


      I'm trying to build a Year/Make/Model related select search. I found a HTML, PHP, and the JQuery Related Select Plugin that i'm trying to convert to use with CF.


      It looks like i can use an array to replace the PHP page that supplies static data:


      $stateID = $_GET['stateID'];

      $countyID = $_GET['countyID'];

      $townID = $_GET['townID'];

      $html = $_GET['html'];


      $states = array();

      $states['MA'] = "Massachusetts";

      $states['VT'] = "Vermont";

      $states['SC'] = "South Carolina";


      $counties = array();

      $counties['MA']['BARN'] = 'Barnstable';

      $counties['MA']['PLYM'] = 'Plymouth';

      $counties['VT']['CHIT'] = 'Chittenden';

      $counties['SC']['ANDE'] = 'Anderson';


      if($stateID && !$countyID && !$townID){

                echo json_encode( $counties[$stateID] );

      } elseif( $stateID && $countyID && !$townID ) {

                echo json_encode( $towns[$stateID][$countyID] );

      } elseif( isset($villages[$stateID][$countyID][$townID]) ) {

                echo json_encode( $villages[$stateID][$countyID][$townID] );

      } else {

                echo '{}';





      I'm tryiing to convert the following into an array so that i can access it from the index.cfm page:

      <cfquery name="qYear" datasource="MyDS" username="MyUser" password="MyPass">

          select distinct YearRange

          from ExactFit2012

          order by YearRange


      <cfquery name="qMake" datasource="MyDS" username="MyUser" password="MyPass">

          select distinct Make

          from ExactFit2012

          order by Make


      <cfquery name="qModel" datasource="MyDS" username="MyUser" password="MyPass">

          select distinct Model

          from ExactFit2012

          order by Model



      <cfset myYear = ListToArray(ValueList(qYear.YearRange)) />

      <cfset myMake = ListToArray(ValueList(qMake.Make)) />

      <cfset myModel = ListToArray(ValueList(qModel.Model)) />








      When i do this i get the error:

      Error Occurred While Processing Request

      Error Executing Database Query.

      [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'Ford'.




      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml">


      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

      <title>jQuery Related Selects</title>

      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

      <script src="src/jquery.relatedselects.min.js" type="text/javascript"></script>



      <style type="text/css">

      body { font:12px helvetica, arial, sans-serif; }




      <script type="text/javascript">




                $("#example-1, #example-3").relatedSelects({

                          onChangeLoad: 'MyArray.cfm',

                          defaultOptionText: 'Choose an Option',

                          selects: {

                                    'Make':                    { loadingMessage:'Loading Year...' },

                                    'YearRange':                    { loadingMessage:'Loading Make...' },

                                    'Model':                    { loadingMessage:'Loading Model...' },

                                    'OverallSize':          {}









      <form id="ymm">

                <select name="YearID">

                <option value="">Choose Year &raquo;</option>

                <cfoutput query="qYear">

                <option value="#YearRange#">#YearRange#</option>





                <select name="Make">

                <option value="">Choose Make &raquo;</option>




                <select name="Model">

                <option value="Model">Choose Model &raquo;</option>




                <select name="OverallSize">

                <option value="">Choose Size &raquo;</option>








      I may be going avout this all woring, but i have tried 3 cfc tutorials with no luck so i'm hoping the JQuery Related Select will do the trick.