cf challenge - make a cf8 cfinput autosuggest work - easy? simple?

I've been all over the internet with no solution. Lot's of rediculous blogs. Others have asked and not received an answer. I'm coming to the "pros". The guys who LIKE to answer questions. Don't fail me now.

Use the following code to start. Change it any way you like. I will take the changed code and test it. If it doesn't work for me, you have to help me find out why. This could be frustrating, I know.

<cfajaximport tags="CFINPUT-AUTOSUGGEST">
<div align="center">
<cfform name="CompSearch" format="html">
<table>
  <tr>
        <td>Company:</td>
    <td><cfinput type="text" name="name" size="30" autosuggest="cfc:cfc.basic.lookupCompany({cfautosuggestvalue})"></td>
  </tr>
</table>  
</cfform>
</div>



      <cffunction name="lookupCompany" access="remote" returntype="query" returnformat="json">
        <cfargument name="search" type="any" required="false" default="">
    <cfset var data="">
    <cfquery datasource="#request.dsn#" name="data">
                  SELECT name
                   FROM companies
      <cfif not arguments.search eq "">WHERE name LIKE '#ARGUMENTS.search#%'</cfif>
      ORDER BY name
    </cfquery>
        <cfreturn data>
      </cffunction>


The goal is simple. Make this autosuggest work.
LVL 1
larksysAsked:
Who is Participating?
 
PluckaConnect With a Mentor Commented:
As I said before if it works without the menu and not with it, there is a javascript conflict between the libraries.

I think you would be better asking for help with that in a JavaScript topic area.
0
 
PluckaCommented:
Have you seen this

http://tutorial7.learncf.com/
0
 
larksysAuthor Commented:
You're in or you're out. Make up your mind.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
larksysAuthor Commented:
I'm using the following url to test.

http://tax.avericom.com/control/companies/vaughn.cfm
0
 
PluckaCommented:
What are you talking about, the code example I posted is an exact working example of what you want. What more do you want exactly since we don't have your database.
0
 
PluckaCommented:
Ok, I'll humor you

http://code.fraser.id.au/vaughn.cfm

This works perfectly. There are two problems with yours that I had to fix other than use different datasource etc.

First the function return type must be String

Second you need to return using the valueList function.

Both of this is demonstrated in that link I sent you

PS: You need to type in uppercase as I didn't want to change much of your code and the sample db is case sensitive.

Working code posted below. What do I win?
vaughn.cfm
<cfajaximport tags="CFINPUT-AUTOSUGGEST">
<div align="center">
<cfform name="CompSearch" format="html">
<table>
  <tr>
        <td>Company:</td>
    <td><cfinput type="text" name="name" size="30" autosuggest="cfc:vaughn.lookupCompany({cfautosuggestvalue})"></td>
  </tr>
</table>  
</cfform>
</div>
 
vaughn.cfc
<cffunction name="lookupCompany" access="remote" returntype="string" returnformat="json">
    <cfargument name="search" type="any" required="false" default="">
 
    <cfset var data="">
 
    <cfquery datasource="cfdocexamples" name="data">
        SELECT parkname
        FROM parks
        <cfif not arguments.search eq "">WHERE parkname LIKE '#ARGUMENTS.search#%'</cfif>
        ORDER BY parkname
    </cfquery>
 
    <cfreturn valueList(data.parkname) />
</cffunction>

Open in new window

0
 
PluckaCommented:
There is stuff in this code that I didn't change to make it as similar as yours as possible that is not needed, if you get it working and want to simplify it, let me know.
0
 
larksysAuthor Commented:
Here is the cfc function with the 2 changes.

      <cffunction name="lookupCompany" access="remote" returntype="string" returnformat="json">
        <cfargument name="search" type="any" required="false" default="">
    <cfset var data="">
    <cfquery datasource="#request.dsn#" name="data">
                  SELECT name
                   FROM companies
      <cfif not arguments.search eq "">WHERE name LIKE '#ARGUMENTS.search#%'</cfif>
      ORDER BY name
    </cfquery>
        <cfreturn valueList(data.name)>
      </cffunction>

I you go to the url above and use "her" you should get at least 3 responses. If I move the query to the cfm page it will work. Change anything you like. I will test it.
0
 
PluckaCommented:
its throwing a JS error. Can you do a test page that has none of that JS menu to see if that is conflicting?
0
 
larksysAuthor Commented:
Good catch, by the way.
0
 
larksysAuthor Commented:
if you go to http://tax.avericom.com/control/companies/vaughn2.cfm you will see the following code work;

<cfajaximport tags="CFINPUT-AUTOSUGGEST">

<div align="center">
<cfform name="CompSearch" format="html">
    <cfquery datasource="#request.dsn#" name="data">
                  SELECT name
                   FROM companies
      ORDER BY name
    </cfquery>
<table>
  <tr>
        <td>Company:</td>
    <td><cfinput type="text" name="name" size="30" autosuggest="#ValueList(data.name)#"></td>
  </tr>
</table>  
</cfform>
</div>
0
 
larksysAuthor Commented:
I've taken out as much as I can find. The original design was by someone else. Still looking.
0
 
PluckaCommented:
Thats worse, gets an error before I even do anthing.

Cant you just do a simple test page with just the code I pasted or your version of it.
0
 
larksysAuthor Commented:
I suspect part of the problem IS the site. But, I will do what I can.
0
 
larksysAuthor Commented:
A "clean site" is http://www.taxtalent.com/vaughn/vaughn.cfm and the code works. There's the rub. Why doesn't it work on the other site?
0
 
larksysAuthor Commented:
I've compared everything I can find on the 2 servers. There are only minor differences. Except the one major difference - cfgrid and cfautosuggest. Anyone care to take a stab at making the code work? Spry widgets like tabbed panels work just fine.
0
All Courses

From novice to tech pro — start learning today.