Skip to main content
Participant
April 16, 2009
Question

Multiple CFSELECT w/multiple CFC queries and arrays - HELP :)

  • April 16, 2009
  • 1 reply
  • 1373 views

Please, need some help here.

I have a form that is populated by CFC queries/arrays...I'm sure there are syntax errors BUT I get no errors AND the page does not populate.

I think I'm close but not quite there yet...the last query I THINK woulld be a query on a query???

HERE IS THE FORM FOLLOWED BY THE CFC

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Add InventoryForm</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<!---
<cfif not isDefined("SESSION.isLoggedIn")>
<p>Sorry, you are not logged in yet.</p>
<cfabort>
</cfif>
--->

<body>

<h2>Add a vehicle to inventory</h2>

<table width="80%">

<cfform action="AddInventoryAction.cfm" method="post">

    <tr>
      <td width="27%" align="right">Stock No:</td>
      <td width="73%"><cfinput type = "Text"
   name = "vehicle_sold_stock_number"
     message="Please enter STOCK NUMBER of the vehicle"
   required="yes"
   size="10"
  maxlength="10"> </td>
    </tr>

<tr>
       <td height="29" align="right">Year:</td>
       <td><cfselect
    name="getVehicleYear"
    bind="cfc:vehicleInfo.getVehicleYear()"
    bindonload="true">
    <option name="0">----</option>
     </cfselect>
  </td>
</tr>

    <tr>
   <td align="right">Vehicle Catagory:</td>
      <td><cfselect name="getVehicleCatagories"
            bind="cfc:vehicleInfo.getVehicleCatagories()"
            bindonload="true">
   <option name="0">----</option>
     </cfselect></td>
    </tr>

<tr>
   <td align="right">Vehicle Make:</td>
      <td><cfselect name="getVehicleMakes"
            bind="cfc:vehicleInfo.getVehicleMakes()"
            bindonload="false" >
   <option name="0">----</option>
     </cfselect></td>
    </tr>
 
<tr>
   <td align="right">Vehicle Model:</td>
      <td><cfselect name="getVehicleModels"
            bind="VehicleInfo.cfc:vehicleInfo.getVehicleModel({getVehicleMakes})"
            bindonload="true">
   <option name="0">----</option>
     </cfselect></td>
    </tr>


<tr>
  <td align="right">Vehicle Body Type:</td>
  <td><cfselect name="bodyType" selected="--Select--">
    <option value="">----</option>
    <option value="2DR">2DR</option>
    <option value="3DR">3DR</option>
    <option value="4DR">4DR</option>
    <option value="Convt">Convt</option>
    <option value="stationWagon">Station Wagon</option>
    <option value="2drSUV">2 Door SUV</option>
    <option value="4drSUV">4 Door SUV</option>
    <option value="RegCabPU">Regular Cab PU</option>
    <option value="ExtCabPU">ExtCab PU</option>
    <option value="CrewCabPU">Crew/QUAD Cab PU</option>
    <option value="MP">MPV</option></cfselect></td>
</tr>
   

<tr>
  <td align="right">Vehicle Interior Trim:</td>
  <td><cfselect name="interiorTrim" >
    <option value="" selected>----</option>
    <option value="2DR">Cloth</option>
    <option value="2DR">Leather</option>
    <option value="2DR">Vinyl</option></cfselect></td>
</tr>

<tr>
   <td align="right">VIN:</td>
      <td><cfinput type = "Text" 
   name = "vehicleVIN"
   message="Please enter vehicle VIN"
   required="yes"
   size="17"
   maxlength="17"></td>
    </tr>

<tr>
   <td align="right">Vehicle Miles:</td>
      <td><cfinput type = "Text" 
   name = "vehicle_sold_mileage"
   message="Please enter VEHICLES MILES of the vehicle"
   required="yes"
   size="15"
   maxlength="15"> </td>
    </tr>

<tr>
   <td align="right">Vehicle Exterior Color:</td>
      <td><cfselect name="vehicleExteriorColor" >
    <option value="" selected>----</option>
    <option value="orange">Orange</option>
    <option value="red">Red</option>
    <option value="lightblue">Light Blue</option>
    <option value="blue">Blue</option>
    <option value="darkblue">Dark Blue</option>
    <option value="yellow">Yellow</option>
    <option value="lightgreen">Light Green</option>
    <option value="green">Green</option>
    <option value="darkgreen">Dark Green</option>
    <option value="burgandy">Burgandy</option>
    <option value="purple">Purple</option>
    <option value="tan">Tan</option>
    <option value="brown">Brown</option>
    <option value="black">Black</option>
    <option value="white">White</option>
    </cfselect></td>
    </tr>

<tr>
   <td align="right">Vehicle Interior Color:</td>
      <td><cfselect name="vehicleInteriorColor" >
    <option value="" selected>----</option>
    <option value="orange">Orange</option>
    <option value="red">Red</option>
    <option value="lightblue">Light Blue</option>
    <option value="blue">Blue</option>
    <option value="darkblue">Dark Blue</option>
    <option value="yellow">Yellow</option>
    <option value="lightgreen">Light Green</option>
    <option value="green">Green</option>
    <option value="darkgreen">Dark Green</option>
    <option value="burgandy">Burgandy</option>
    <option value="purple">Purple</option>
    <option value="tan">Tan</option>
    <option value="black">Black</option>
    <option value="brown">Brown</option>
    <option value="white">White</option>
    </cfselect></td>
    </tr>

<tr>
  <td align="right">Transmission Type:</td>
      <td><cfselect name="vehicleTransmissionType" >
    <option value="" selected>----</option>
    <option value="3SpdAuto">3 Speed Auto w/o OD</option>
    <option value="3SpdAutoOD">3 Speed Auto w/OD</option>
    <option value="4SpdAuto">4 Speed Auto w/o OD</option>
    <option value="4SpdAutoOD">4 Speed Auto w/OD</option>
    <option value="3spdManual">3 Speed MT</option>
    <option value="4spdManual">4 Speed MT</option>
    <option value="5spdManual">5 Speed MT</option>
    <option value="6spdManual">6 Speed MT</option>
    </cfselect></td>
    </tr>

<tr>
   <td align="right">Engine Type:</td>
      <td><cfselect name="vehicleEngineType" >
    <option value="" selected>----</option>
    <option value="3cyl">3 Cyl</option>
    <option value="4cyl">4 Cyl</option>
    <option value="5cyl">5 Cyl</option>
    <option value="6cyl">6 Cyl</option>
    <option value="8cyl">8 Cyl</option>
    <option value="10cyl">10 Cyl</option>
    <option value="12cyl">12 Cyl</option>
    </cfselect></td>
    </tr>

<tr>
   <td align="right">Title In::</td>
      <td><cfselect name="interiorTrim" required="yes" >
    <option value="" selected>----</option>
    <option value="Yes">Yes</option>
    <option value="No">No</option></cfselect></td>
    </tr>

<tr>
   <td align="right">Wheels</td>
      <td><cfinput type = "Text" 
   name = "vehicle_sold_wheels"
   message="What Kind of wheels?? (Y/N)"
   required="yes"
   size="10"
   maxlength="10"> </td>
    </tr>

<tr>
   <td align="right">Vehicle Exterior Condition</td>
   <td><cfselect name="exteriorCondition">
      <option value="" selected>----</option>
    <option value="Poor">Poor</option>
    <option value="Average">Average</option>
    <option value="AboveAverage">Above Average</option>
    <option value="Excellent">Excellent</option></cfselect> </td>
    </tr>

<tr>
   <td align="right">Vehicle Interior Condition</td>
   <td><cfinput type = "Text"
   name = "vehicle_sold_interior"
   message="Please enter INTERIOR CONDTION of the vehicle"
   required="yes"
   size="15"
   maxlength="15"> </td>
    </tr>

 
<tr>
   <td align="right">Vehicle Over All Condition</td>
   <td><cfinput type = "Text"
   name = "vehicle_sold_overall_condition"
   message="Please enter OVERDALL CONDITION (EXCELLENT, FAIR, ETC) of the vehicle"
   required="yes"
   size="15"
   maxlength="15"> </td>
    </tr>

<tr>
   <td align="right">Number of Keys</td>
      <td><cfinput type = "Text" 
   name = "vehicle_sold_numkeys"
   message="Please enter NUMBER OF KEYS for the vehicle"
   required="yes"
   size="1"
   maxlength="1"> </td>
    </tr>

<tr>
   <td align="right">Number of Remotes</td>
      <td><cfinput type = "Text" 
   name = "vehicle_sold_numremotes"
   message="Please enter the number OF REMOTES the vehicle"
   required="yes"
   size="1"
   maxlength="1"> </td>
    </tr>

    <tr>
      <td> </td>
      <td><cfinput type="submit" name value="Add To Inventory" validate="submitonce"></td>
    </tr>

  </cfform>

</table>

</body>

</html>

CFC


<cfcomponent>
      
<!--- 1st FUNCTION get array of Vehicle Years--->       
<cffunction name="getVehicleYear" returntype="array" access="remote" hint="Get Vehicle Years for AJAX CFSELECTS">
       
  <!--- Define variables --->
  <cfset var data="">
       <cfset var result=ArrayNew(1)>
  <cfset var i=0>
        
  <!--- Only 1 query for this method gets vehicle years --->
        <cfquery name="getVehicleYear" datasource="cucar">
   SELECT vehicle_year
   FROM t_vehicle_years
   ORDER BY vehicle_year DESC
  </cfquery>
       
<!--- THINKING THIS WOULD BE A ONE DIMENSIONAL ARRAY JUST PULLING YEARS --->
 
  <!--- Convert query results to array --->
  <cfloop from="1" index="i" to="#ArrayLen(vehicle_year)#" >
        <cfset result[1]=data.vehicle_year>
       </cfloop>
  
  <!--- And returns the years --->
       <cfreturn results>
  
</cffunction>
 

  
<!--- 2nd FUNCTION get array of vehicle catagories --->       
<cffunction name="getVehicleCatagories" access="remote" returntype="array" hint="Get Vehicle Catagories for AJAX CFSELECTS">
 
  <!--- Define variables --->       
        <cfset var data="">
  <cfset var result=ArrayNew(2)>
  <cfset var i=0>
 
  <cfset result=ArrayNew(2)>
  <cfset category[1][1]="vehicleCategoryAsian">
  <cfset category[1][2]="VehicleMakeAsian">
 
  <cfset category[2][1]="vehicleCategoryDomestic">
  <cfset category[2][2]="VehicleMakeDomestic">
 
  <cfset category[3][1]="vehicleCategoryEuropean">
  <cfset category[3][2]="VehicleMakeEuropean">
  
 
  <!--- Only 1 query gets vehicle category orgin, ie domestic, asian or european --->
  <cfquery name="getVehicleCatagories" datasource="cucar">
   SELECT t_vehicle_categories_orgin.vehicle_category_orgin_id, t_vehicle_categories_orgin.vehicle_category_orgin
   FROM t_vehicle_categories_orgin
   ORDER BY t_vehicle_categories_orgin.vehicle_category_orgin
  </cfquery>
 
   <!--- Convert query results to array --->
   <cfset getVehicleCatagories = arrayCatagories(1)>
                <cfloop from="1" to="#data.recordcount#" index="i">
    <cfset arrayCatagories[1] = data.vehicleCatagoryAsian>
                <cfset arrayCatagories[2] = data.getVehicleEuropean>
    <cfset arrayCatagories[3] = data.getVehicleDomestic>
    </cfloop>
   
  <!--- And returns catagories --->
       <cfreturn result>
  
</cffunction>


<!--- 3rd FUNCTION get array of Makes --->       
<cffunction name="getVehicleMakes" access="remote" returntype="array" hint="Get Vehicle Makes for AJAX CFSELECTS">
 
  <!--- Define variables --->       
        <cfset var vehicleMakes="">
  <cfset var result=ArrayNew(2)>
      <cfset var i=0>

  <!--- 1st query of this method gets vehicle IF asian --->
  <cfquery name="getVehicleMakeAsian" datasource="cucar">
   SELECT vehicle_asian_mfg
   FROM t_vehicle_manufactures_asian
   ORDER BY vehicle_asian_mfg ASC
  </cfquery>
 
  <!--- 2nd query of this methodgets vehicle IF european --->
  <cfquery name="getVehicleMakeEuropean" datasource="cucar">
   SELECT t_vehicle_manufactures_european_id, t_vehicle_manufactures_european_make
   FROM t_vehicle_manufactures_european
   ORDER BY t_vehicle_manufactures_european_make
  </cfquery>
 
  <!--- 3rd query of this method gets vehicle IF domestic --->
  <cfquery name="getVehicleMakeDomestic" datasource="cucar">
   SELECT vehicle_domestic_id, vehicle_domestic_makes
   FROM t_vehicle_manufactures_domestic
   ORDER BY vehicle_domestic_makes
  </cfquery>
 
<!--- THE IDEA BEING TO PULL MAKES DEPENDING ON CATEGORY SELECTED ABOVE - WOULD THIS BE A QofQ??   --->
 
  <!--- Convert query results to array --->
  <cfset getVehicleMakes = arrayMakes(2)>
                <cfloop from="1" to="#data.recordcount#" index="i">
    <cfset arrayMakes[1] = data.getVehicleAsian>
                <cfset arrayMakes[2] = data.getVehicleEuropean>
    <cfset arrayMakes[3] = data.getVehicleDomestic>
                </cfloop>
        
        <!--- And return it ---> 
         <cfreturn result>
</cffunction>

<!--- =================== WOULD THIS BE A QUERY OF A QUERY TOO?? IF SO HOW??=================== --->
  
<!--- 4th FUNCTION get array of Models --->       
<cffunction name="getVehicleModels" access="remote" returntype="array" hint="Get Vehicle Models for AJAX CFSELECTS">

<cfset var vehicleModels="">
  <cfset var result=ArrayNew(1)>
      <cfset var i=0> 
 
<!---  query gets vehicle model depending on category and/or make selected?? --->
  <cfquery name="getVehicleModel" datasource="arrayMakes">
   SELECT *
   FROM arrayMakes
   WHERE ID = #arrayMakes#
   ORDER BY Name
        </cfquery>
 
  <!--- THINKING THIS WOULD BE A ONE DIMENSIONAL ARRAY JUST PULLING MODELS --->
 
  <!--- Convert query results to array --->
  <cfloop from="1" index="i" to="#ArrayLen(vehicleModel)#" >
        <cfset result[1]=data.vehicleModel>
       </cfloop>
 
  <!--- And return it ---> 
         <cfreturn result>
 
      
  
        </cffunction>
</cfcomponent>

Thanks

Chuck In Atlanta

This topic has been closed for replies.

1 reply

Inspiring
April 16, 2009

First, make things simple for yourself by putting a cfabort after the first cfselect that is not populating.  Then turn on debugging.  Find the query that was supposed to populate this select and see how many records it returned.

Participant
April 16, 2009

Dan,

Thank you very much for your prompt direction.

Did it...

The query does work both from navicat and CF8 test of the recordset...returns 2010 - 1980.

I get NO errors and no, nothing populates??

Chuck