Copy link to clipboard
Copied
hi i have a coldfusion code in which the binding is failing and the value is not being retrived from database, i really do not know why?
first of all i will tell my table structutre
id, state, city in table zips
now i use the following code to bind the expression:
<tr><td><strong>State</strong></td>
<td><select name="state" class="textfield_effect">
<cfoutput query="getData">
<option value="#sstate#">#sstate#</option>
</cfoutput>
</select>
<cfselect name="city" bindOnLoad="yes" bind="cfc:cfc.statecity.CitySelect({State})"/>
</td>
</tr>
now the cfcfunction is in below window:
i invoke the getdata as:
<cfinvoke component="#request.cfcPath#.tools" method="gData" newf="1" returnvariable="getData"/>
what in getdata is as:
<cffunction access="public" name="gData" returntype="query">
<cfargument name="newf" default="" required="no">
<cfset var myset = "">
<cfquery name="myset" datasource="#request.dsn#">
<cfif isdefined('arguments.newf') and arguments.newf eq 1>
SELECT DISTINCT(state) as sstate
from zips
GROUP by state
<cfelse>
SELECT * from zips
</cfif>
</cfquery>
<cfreturn myset>
</cffunction>
<cfcomponent>
<cfproperty name="name" type="string">
<cffunction name="CitySelect" access="remote" returntype="array">
<cfargument name="State" type="string" required="true">
<cfquery name="myset" datasource="#request.dsn#" username="#request.user#" password="#request.pass#">
SELECT city,state
FROM zips
WHERE State = <cfqueryparam cfsqltype="cf_sql_varchar" value="#state#">
</cfquery>
<cfset list = arraynew(2)>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#myset.RecordCount#">
<cfset list[1]= myquery.state>
<cfset list[2]= myquery.city>
</cfloop>
<cfreturn list>
</cffunction>
</cfcomponent>
when i see from firebug, i see the this
[]
with no value.
i debugged and found this error:
error:bind: Element not found: State
error:bind: Bind failed, element not found: State
please guide me
Copy link to clipboard
Copied
Hi,
Is it perhaps a matter of upper- or lowercase?
Your source select element's name is 'state' and not 'State'.
Try putting the bound parameter as {state} instead of {State}.
Cheers,
Bert.