Have a pair of related select lists...first one is country, then when the
country is selected, states load in the second select. The first select,
which gets its data from a CFC, works fine, but when the page loads, it
gives a "Bind failed, element not found: country" error. The pertinent
code:
The form fields in the CFM page:
<tr valign="middle">
<td align="right" class="formNotRequired">Country:</td>
<td><cfselect name="country"
bind="cfc:site.extensions.cfc.utils.getCountries()" bindonload="true"
display="printable_name" value="country" style="width:
100%;"></cfselect></td>
</tr>
<tr valign="middle">
<td align="right" class="formNotRequired">State:</td>
<td><cfselect name="state"
bind="cfc:site.extensions.cfc.utils.getstates({country})"
display="stateValue" value="state" style="width: 100%;"></cfselect></td>
</tr>
And the methods in the CFC:
<cfcomponent>
<cffunction name="getCountries" access="remote" returntype="query">
<cfquery name="getCountries" datasource="#application.dsn#">
SELECT DISTINCT FBB.country, UC.printable_name
FROM _tblFBBuilders FBB
LEFT JOIN tblUtilCountry UC
ON FBB.country = UC.iso
UNION
SELECT '' AS country, ' - Select Country - ' AS printable_name
ORDER BY UC.printable_name
</cfquery>
<cfreturn getCountries>
</cffunction>
<cffunction name="getstates" access="remote">
<cfargument name="country" required="yes">
<cfquery name="getStates" datasource="#application.dsn#">
SELECT DISTINCT FBB.state, FBB.state AS stateValue
FROM _tblFBBuilders FBB
WHERE FBB.country = <cfqueryparam cfsqltype="CF_SQL_CHAR"
value="#arguments.country#">
UNION
SELECT '' AS state, ' - Select State - ' AS stateValue
ORDER BY FBB.state
</cfquery>
<cfreturn getstates>
</cffunction>
</cfcomponent>
Any obvious mistakes here?
Thanks,
Pete
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346872
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm