Skip to main content
Inspiring
October 15, 2007
Question

cfinput autosuggest

  • October 15, 2007
  • 3 replies
  • 729 views
I'm a little frustrated with CF8 and the new Spry functions. I'm trying to convert my old autosuggests to the cfinput and binding with a function in a cfc. I'm trying to follow the examples but getting the following error;

Error invoking CFC /components/tsijobads cfc. Internal server error (enable debugging .......)

The code is;

<cffunction name="getCompanies" access="remote" returntype="array" output="false" description="Returns submission titles">
<cfargument name="term" type="string" required="true">
<cfset var CnameQry = "">
<cfquery name="CnameQry" datasource="AS400" dbtype="ODBC" maxrows="50">
SELECT rtrim(ltrim(csnam1)) as cname, rtrim(ltrim(csstat)) as state, rtrim(ltrim(cscity)) as city, csrec## as companyid
FROM cstatic
WHERE UPPER(csnam1) LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#ucase(left(arguments.term,255))#%">
order by csnam1,cscity
</cfquery>
<!--- Build result array --->
<cfset Carray = listotarray(CnameAry.csnam1)>

<cfreturn Carray>

</cffunction>



<cfinput name="sfCname#counter#" id="sfCname#counter#" autosuggest="cfc:400comps.tsijobads.getCompanies({cfautosuggestvalue})" maxResultsDisplay="50">
This topic has been closed for replies.

3 replies

larksysAuthor
Inspiring
October 17, 2007
Started from scratch using cfinput and autosuggest. It works fine. I just can't find the error in the above code.
larksysAuthor
Inspiring
October 16, 2007
This code works;

<cfinput name="sfCname#counter#" id="sfCname#counter#" size="40" autosuggest="cfc:400comps.tsijobads.getCompanies({cfautosuggestvalue})" maxResultsDisplay="50">

<cffunction name="getCompanies" access="remote" returntype="string">
<cfargument name="term" type="any" required="false" default="">
<cfset var CnameQry = "">
<cfquery name="CnameQry" datasource="AS400" dbtype="ODBC" maxrows="50">
SELECT rtrim(ltrim(csnam1)) as cname, rtrim(ltrim(csstat)) as state, rtrim(ltrim(cscity)) as city, csrec## as companyid
FROM cstatic
WHERE UPPER(csnam1) LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#ucase(left(arguments.term,255))#%">
order by csnam1,cscity
</cfquery>
<cfreturn ValueList(CnameQry.cname)>
</cffunction>

---------------------------------------------------------------------------------------------------
This code does not;

<cfinput type="text" name="sfiname#counter#" id="sfiname#counter#" autosuggest="cfc:400comps.tsijobads.getIndividualsH({cfautosuggestvalue})" maxResultsDisplay="50">

<cffunction name="getIndividualsH" access="remote" returntype="string">
<cfargument name="term" type="any" required="false" default="">
<cfset var IndivQry = "">
<cfquery name="IndivQry" datasource="AS400" dbtype="ODBC" maxrows="50">
SELECT rtrim(ltrim(isfnam)) as FNAME, rtrim(ltrim(islnam)) as LNAME, rtrim(ltrim(istitl)) as ITITLE, iswfon as WPHONE, isrec## as RECNUM
FROM istatic
WHERE UPPER(islnam) LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#ucase(left(arguments.term,255))#%">
ORDER by islnam,isfnam
</cfquery>
<cfreturn ValueList(IndivQry.isfnam)>
</cffunction>

----------------------------------------------------------------------------------------------------
I don't think the mapped folder is the problem. I solved part of the problem by changing the function output type to "string" and returning a list. Some of the examples and cfml ref are just plain wrong. Hard to believe, huh.

I just noticed that I have a type of "text" on one cfinput and not the other. I just tested it without "text" and it didn't make a difference.

Inspiring
October 16, 2007
larksys wrote:

> Error invoking CFC /components/tsijobads cfc. Internal server error (enable
> debugging .......)

> <cfinput name="sfCname#counter#" id="sfCname#counter#"
> autosuggest="cfc:400comps.tsijobads.getCompanies({cfautosuggestvalue})"
> maxResultsDisplay="50">
>

your error says your cfc is in /components/tsijobads
your cfinput bind says it is in 400comps.tsijobads

either on of them is a typo or you are trying to use a mapped cf folder,
which is not allowed with ajax calls.

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com