November 16th, 2011, 01:34 AM
Displaying the query result
I am stuck up with looping a query within a function. For example, I have a function within which has a query which returns the names which starts with 'a'. But i am able to get only one value (first value) from the database.Actually in the db we have more than 1 values for this query.How should i loop the query within the function? Any help is appreciated...
<cffunction name="getNames" returntype="any">
<cfargument name="letter" required="true">
<cfquery name="getNamesfrmDB" datasource="test">
select * from employee where firstname like '#arguments.letter#%'
Thanks in advance.....
November 16th, 2011, 10:13 AM
<cfset results = getNames( 'a' ) />
November 17th, 2011, 12:02 AM
hey thank you..it worked
November 17th, 2011, 01:00 AM
I have a question on cfajaxproxy.
I am using cfajaxproxy to fetch the data from db and display it. For example, I have a dropdown which have the country code. On change of the countrycode, it should display the correct country name from db. but its returning undefined value. Below is the code
<cfajaxproxy cfc="cfcProxy" >
var object=new cfcProxy();
alert("Problems running proxy");
Country code: <select name="code" id="code" onchange="getCountry();">
<cffunction name="getCountrylist" access="remote" returntype="query">
<cfargument name="code" required="yes">
<cfquery name="getCountrylistfrdisp" datasource="test">
select country from countrycode where code = "#arguments.code#"->
November 17th, 2011, 03:36 PM
November 17th, 2011, 10:27 PM
Is there anything that i am missing in my code?
Thanks in advance...
November 18th, 2011, 12:43 AM
Are you sure it's "result.value"?
November 18th, 2011, 01:00 AM
I just wanted to alert and check whether the result is coming back to the page or not since the page goes blank after selecting the dropdown value. If i am not alerting, then in the page its displaying [object Object]. So to fetch that value i was trying result.value.
November 23rd, 2011, 07:43 AM
There is an attribute for the cfajaxproxy tag called jsclassname that you need. Your tag should look as follows:
<cfajaxproxy cfc="cfcProxy" jsclassname="myProxy" />
Then in your JS you refer to the jsclassname rather than the cfc name such as:
var object = new myProxy();
Then continue on from there.
Hope that helps.