0

I want to bind this cfc to my cfselect:

This is my code for the cfc:

<cfcomponent output="false">
<cffunction name="getrates" returntype="query" output="false" access="remote">
<cfargument name="productno" required="yes" default="0" hint="Need productno.">
<cfset var getrate = "">
<cfquery name="getrate" datasource="xxxxxx">
     select distinct  ratecode, b.rateid as rateid
     from productnos a , rates b
     where a.productid = b.productid and a.productsubid = b.productsubid
        and a.productno = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.productno#">
        and (b.validto is null or b.validto > '2013-09-01')
</cfquery>
<cfreturn getrate> 
</cffunction>
</cfcomponent>

and this is my code for test.cfm:

 <CFPARAM name="FORM.productnumber" default="">
 <cfif structKeyExists(form,'submit') >
<cfset productno = #FORM.productnumber#>
 <table border="1" cellpadding="5" cellspacing="0" bordercolor="SeaGreen">  
   <tr>  
       <td colspan="2" bgcolor="DarkSeaGreen" style="color:Snow; font-size:large" align="center">  
         Choose Option For Tour 
            </td>  
         </tr>  
         <tr valign="top">  
            <td style="color:DarkSeaGreen; font-weight:bold">  
            Select Option  
            </td>  
            <td >  
            <cfform name="selectrate" method="post" format="html">  
                <cfselect name="rateid" bind="cfc:pricelist.getrates({productno})" display="ratecode" value="rateid" bindonload="yes" />

            </cfform>  
             </td>  
        </tr>  
    </table>  

<br />

<CFELSE>
 <CFOUTPUT>
  <cfform  action="testniva.cfm" method="POST">
    <p>Please enter the product number<br />
      <!--- include the most recent value of the submitted form, if you like, by simply setting the value to the variable --->
       <cfinput type="text" name="productnumber"></p>
       <p><cfinput type="submit" name="submit" value="Submit"></p>
   <p><cfinput type="reset" Name="Reset" value="Cancel">    </p>
   </cfform>
 </CFOUTPUT>
</CFIF>     

I cannot get the cfselect to bind because it said productno is undefined. Not sure what I need to do. If I replace bind="cfc:pricelist.getrates({productno}) to bind="cfc:pricelist.getrates(101) than it will bind, so I think somehow the productno didn't get carried over.

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
Niva-L
  • 73
  • 2
  • 8
  • Never mind, I found the problem. I need to put bindonload in the cfselect – Niva-L Sep 11 '13 at 00:11
  • FYI, for the code that you displayed, there's doesn't appear to be a reason to have it be an Ajax call since the query isn't dynamic. – Busches Sep 11 '13 at 11:36
  • actually what I want to do is have a self submit form with a text box ask for productno, pass that productno to the cfselect, but I have having difficulty with passing the variable. Can you tell me what I need to do to get that bind recognize my variable. I edited the original post for the code. – Niva-L Sep 11 '13 at 19:09
  • Wanna create a proper answer and then mark this as answered? – Adam Cameron Sep 12 '13 at 12:48

0 Answers0