Skip to main content
Inspiring
September 16, 2009
Question

how do you reference a specific value in a bind value?

  • September 16, 2009
  • 1 reply
  • 682 views

Hi-

I'm working with cfform and am doing binds to cfcs, for example:

<cfinput type="text" name="psistrength" bind="cfc:controller.Controller.getMixPsistrength({mixdesign})" bindattribute="value" bindonload="yes" />

I've listed the cfc's method below. Since my query is returning rows with 4 columns I'd like the freedom to display any of the 4 columns as I need to. Does anyone know how to reference a specific value in:

     ~the cfinput type=text tag, as I described above?

     ~how about if I do a binding from a cfselect value and I want to bind a cfc to a cfgrid, using that cfselect value as the filter for my cfc's method in my bind call?

    <cffunction name="getMixPsistrength"  access="remote" returntype="array" output="yes">
        
         <cfargument name="mixdesign" type="string" required="yes" />
        
         <cfset var qGetMixPsistrength= "" />
         <cfset var qPsi=arrayNew(2) />
         <cfset var j=0>
        
         <cfquery name="qGetMixPsistrength" datasource="#request.DSN#">
             select id, psistrength, colorvalue, pressure
             from concretemixnumbers
             where mixnumber='#ARGUMENTS.mixdesign#'
         </cfquery>
        
         <cfloop from="1" to="#qGetMixPsistrength.recordcount#" index="j">
             <cfset qPsi[1]=qGetMixPsistrength.id/>
             <cfset qPsi[2]=qGetMixPsistrength.psistrength/>

            <cfset qPsi[3]=qGetMixPsistrength.colorvalue/>

            <cfset qPsi[4]=qGetMixPsistrength.pressure/>  
        </cfloop>
       
        <cfreturn qPsi/>
    </cffunction>

Thanks in advance,

Rich

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    September 20, 2009

    This should  give you a flavour of binding in cfinput and in cfselect:

    cities.cfc

    =======

    <cfcomponent>
        <cffunction name="getCity" access="remote" returntype="array">
            <cfset var cities = arrayNew(2)>
            <cfset cities[1][1]="US">
            <cfset cities[1][2]="New York">
            <cfset cities[2][1]="JP">       
            <cfset cities[2][2]="Tokyo">
            <cfset cities[3][1]="FR">       
            <cfset cities[3][2]="Paris">
            <cfset cities[4][1]="BR">       
            <cfset cities[4][2]="Rio de Janeiro">
            <cfreturn cities>
        </cffunction>
    </cfcomponent>

    city.cfm

    =======

    <cfform preservedata="yes">
        country code: <cfinput bind="{cityList}" name="country"><br>
        city: <cfinput bind="{cityList.text}" name="city"><br>

        <!--- use your own cfc path here --->
        city list: <cfselect name="cityList" bind="cfc:workspace.bindTest.cities.getCity()" bindonload="true" />
    </cfform>