0
votes

I am populating a cfselect box using the bind attribute. I'd like to be able to make my selection from the two drop downs and then populate a CFTEXTAREA based on that selection. I thought I could just issue a similar bind attribute command but the textarea outputs:

[object Object]

CF8 documentation says that this is possible? What am I missing?

Form Code:

<cfselect name="descriptionDD" value="description" bind="cfc:cfcs.menudata.getData()" bindonload="true" />

<cftextarea name="detailDD" value="service_detail" bind="cfc:cfcs.menudata.getDetail({descriptionDD})" bindonload="true" />

CFC Code:

<cfcomponent>
<!---First Select Box --->
<cffunction name="getData" access="remote" returntype="query">

    <!--- Function to get data from datasource --->
    <cfquery name="data" datasource="ezpay">
    select description
    from service_descriptions
    order by description
    </cfquery>

    <!--- Return results --->
    <cfreturn data>
</cffunction>

<!---Second Select Box --->
<cffunction name="getDetail" access="remote" returnType="query">
        <cfargument name="description" type="any" required="true">

            <cfquery name="dataDetail" datasource="ezpay">
            SELECT service_detail
            from service_descriptions
            WHERE description = '#ARGUMENTS.description#'
            ORDER BY ID ASC
            </cfquery>

        <cfreturn dataDetail>
</cffunction>

</cfcomponent>
1

1 Answers

3
votes

but the textarea outputs: [object Object]

That usually means you are returning a complex object where a simple string is expected instead. [object Object] is essentially the string representation of the complex object (in your case a query).

TextArea's are designed to display a single value. So your bind function should return a string, not a query object.

<cffunction name="getDetail" access="remote" returnType="string">
    <cfargument name="description" type="any" required="true">

    <!--- localize function variables --->
    <cfset var dataDetail = "">
    <cfquery name="dataDetail" datasource="ezpay">
        SELECT service_detail
        FROM   service_descriptions
        <!--- adjust cfsqltype if needed --->
        WHERE description = <cfqueryparam valu="#ARGUMENTS.description#" cfsqltype="cf_sql_varchar">
        ORDER BY ID ASC
    </cfquery>

    <cfreturn dataDetail.service_detail>
</cffunction>