Here is what I am up against: I am trying to change the content of a CFDIV based on the selection from a CFSelect box.
To do this I have bound the CFDiv to a CFC and I am trying to return two columns from my query that is executed in that CFC; Alert_Status AND Alert_Priority. These values will be queried based on a selection from the CFSelect box in my CFM page. Company_Name is the value passed to the CFC from the selection in the CFSelect box. Once the query in the CFC is run, I would like to display the results in a DIV on that same CFM page as the select box.
Here is the CFC:
<!---First Slect Box --->
<cffunction name="getData" access="remote" returntype="query">
<cfoutput>
<!--- Function to get data from datasource --->
<cfquery name="data" datasource="#datasource#">
select company_name, customer_id
from customer_table
where status <> '0'
order by company_name
</cfquery>
</cfoutput>
<!--- Return results --->
<cfreturn data>
</cffunction>
<cffunction name="getDetail" access="remote" returnType="string">
<cfargument name="company_name" type="any" required="true">
<!--- localize function variables --->
<cfset var dataDetail = "">
<cfoutput>
<cfquery name="dataDetail" datasource="#datasource#">
SELECT tax_rate
FROM customer_table
<!--- adjust cfsqltype if needed --->
WHERE company_name = <cfqueryparam value="#ARGUMENTS.company_name#" cfsqltype="cf_sql_varchar">
</cfquery>
</cfoutput>
<cfreturn dataDetail.tax_rate>
</cffunction>
<cffunction name="getAlerts" access="remote" returnType="query">
<cfargument name="company_name" type="any" required="true">
<!--- localize function variables --->
<cfset var alertDetail = "">
<cfoutput>
<cfquery name="getID" datasource="#datasource#">
select customer_id
from customer_table
where company_name = <cfqueryparam value="#ARGUMENTS.company_name#" cfsqltype="cf_sql_varchar">
</cfquery>
<cfquery name="alertDetail" datasource="#datasource#">
SELECT *
FROM customer_alerts
<!--- adjust cfsqltype if needed --->
WHERE customer_id = <cfqueryparam value="#getID.customer_id#" cfsqltype="cf_sql_varchar"> AND alert_status = 'on'
</cfquery>
</cfoutput>
<cfreturn alertDetail>
</cffunction>
I am trying to display the query results for the query AlertDetail in a div on my main page.
Here is the portion of my CFM page that relates to this CFC:
<cfdiv name="test" id="test" type="text" bind="cfc:cfcs.taxdata.getAlerts({company_name})" bindonload="true" bindattribute="value" rows="2" cols="2" readonly="yes"></cfdiv>
Any help would be greatly appreciated. Thanks. -Brian
div
. A text box bind will be expecting a simple value, like a string. A query is a complex object, which is probably causing an error. Check the ajax debugger. Not related to your question, but .. you do not need to putcfoutput
tags around queries. Any#variables#
within the cfquery tag will be automatically evaluated. Also, it does not look like there is any need for two queries ingetAlerts()
. Just use aJOIN
between the two tables. - Leigh