我想将此cfc绑定到我的cfselect
:
这是我的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>
这是我的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>
我无法让cfselect
绑定,因为它说productno is undefined
。不确定我需要做什么。如果我将bind="cfc:pricelist.getrates({productno})
替换为bind="cfc:pricelist.getrates(101)
而不是它将绑定,那么我认为productno
不会被转移。