Solved

my two related select binding failed

Posted on 2009-05-13
9
396 Views
Last Modified: 2013-12-20
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>&nbsp;
      <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[i][1]= myquery.state[i]>
    <cfset list[i][2]= myquery.city[i]>
  </cfloop>
  <cfreturn list>
</cffunction>
</cfcomponent>

Open in new window

0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24381771
you are terminating your <cfselect> tag by using an empty tag closing tag ( /> ) in it - that prevents any <option> tags to be added to this <cfselect> by the bnding.

you need to properly close your <cfselect> tag by using a closing tag instead of terminating it. change your <cfselect> to this:

<cfselect name="city" bindOnLoad="yes" bind="cfc:cfc.statecity.CitySelect({State})"></cfselect>

Azadi
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 24381783
changing that as you suggested still not solved my issue. i get this error:


<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">
error:bind: Element not found: State
 
error:bind: Bind failed, element not found: State

Open in new window

0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24382320
javascript IS case-sensitive. if your <select> has name="state" (lowercase first letter), then you need to bind to {state}, NOT {State}.

plus, you should probably add ID="sate" attribute to your <select name="state">, because, iirc, cf's js that works behind the binding uses getElementById() js function...

Azadi
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 24382513
i changed, i added the element ID in state select

i get this error:
<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">
error:http: Error invoking CFC /ibestcity/corecontrol/cfc/statecity.cfc : Element STATE is undefined in a Java object of type class [Ljava.lang.String;.

Open in new window

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 24383511
Dude, I changed a bit of code in the CFC to make it a simple query. the query i changed is below:

it showed me this error:


<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">
error:bind: Bind failed for select box city, value and/or display attributes must be specified on the cfselect tag when binding to a query
 
Now the cfc function i changed.
 
<cfcomponent>
<cfproperty name="name" type="string">
<cffunction name="CitySelect" access="remote" returntype="query">
  <cfargument name="state" type="string" required="true">
  <cfquery name="myset" datasource="#request.dsn#" username="#request.user#" password="#request.pass#">
	SELECT *
    FROM zips 
    WHERE state = <cfqueryparam cfsqltype="cf_sql_varchar" value="#state#">
  </cfquery>
  <cfreturn myset>
</cffunction>
</cfcomponent>
 
 
iopened firebug to see what is happening, i got the following stuff.:
 
 {"COLUMNS":["FIPS","ZIPCODE","STATE","PLACE"],"DATA":[[1,143001.0,"Punjab","Amritsar"],[2,144001.0
,"Punjab","Jalandhar"]]}
  
can u guide me what is happening and what i do now

Open in new window

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 24383514
ignore this : = <input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 24385759
can anybody tell me how i do this, my project is stucked due to this, please experts<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 24385812
do as the error says: add DISPLAY and VALUE attributes to your <cfselect> tag!

<cfselect name="city" bindOnLoad="yes" bind="cfc:cfc.statecity.CitySelect({state})" DISPLAY="place" VALUE="place"></cfselect>

Azadi
0
 
LVL 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 31581100
Thanks Azadi
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question