Skip to main content
October 18, 2008
Question

cfselect bind value for query field

  • October 18, 2008
  • 1 reply
  • 983 views
I have two cfselect drop downs. The first is populated by a query in a cfc. The return is a list of field names. I would like the user to be able to select from the first cfselect <field name> and populate the second cfselect with the values from a query that used the field name selected from the first cfselect choice.

Is this possible and how do I accomplish this? I keep getting an error: "...values returned from getValues function is not of type query..."

Thanks for any help.

here is the code:

<cffunction name="getFields" access="remote" returntype="string">
<cfargument name="search5" type="any" required="false" default="">

<!--- Define variables --->
<cfset var result="">

<!--- Do search --->
<cfquery name="fieldNameQry" datasource="Livermore_SQL">
select *
from LU_Assessor
order by FieldNameLU
</cfquery>

<!--- And return it --->
<cfreturn ValueList(fieldNameQry.FieldNameLU)>
</cffunction>

<cffunction name="getValues" access="remote" returntype="string">
<cfargument name="search6" type="any" required="false" default="">

<!--- Define variables --->
<cfset var result="">

<!--- Do search --->
<cfquery name="valuesQry" datasource="Livermore_SQL" maxrows="20">
select #ARGUMENTS.search6#
from CITY
</cfquery>

<!--- And return it --->
<cfreturn ValueList(search6)>
</cffunction>

<tr>
<td>
<cfselect name="FieldName" style="font-size: 10px;"
query="fieldNameQry"
value="FieldNameLU" display="FieldNameLU">
<option selected>Select Field...</option>
</cfselect>
</td>
<td>
<cfselect name="ValueLU" style="font-size: 10px;"
bind="cfc:srchValues.getValues({FieldName})" bindonload="false">
<option selected>Values...</option>
</cfselect>
</td>
</tr>
This topic has been closed for replies.

1 reply

Inspiring
October 18, 2008
Look at the returntype attribute of your cffunction tag.
October 22, 2008
Dan,

Thanks for the suggestion and I can get it to work if the returntype is set to query, but only if I declare the field and display values in the second cfselect. I would really like the value and display paramaters of the second cfselect to be variables - because there are a few different possiblities. Is this possible?

For example the first cfselect selection will determine what field will be queried and then returned to the second cfselect.

Any ideas?
October 27, 2008
I ended up accomplishing this by creating an array and then passing the array to the drop down.