Skip to main content
Participant
February 15, 2010
Question

Auto-suggest - I am stuck!

  • February 15, 2010
  • 1 reply
  • 634 views

Okay, so here is my delima.

I have an auto-suggest drop down (a list of law firms).  Once a law firm is selected from the auto-suggest, you click on the "ADD" button and the law firm name and is passed along  to a text box.  Once it is added to a txt box, the law firm name (along with the ID) needs to be saved back to the database.

I have got the auto-suggest part to work but I can't seem to add the chosen law firm name and ID, to the txt field, and then save it to the database.

Here is what I have so far. If you need further clarification, please let me know.

------------------------------------------------------------------------------------------------------------------------------------------

<cfquery name="GetOC" datasource="#datasourcename#">
    SELECT * FROM table
    WHERE CounselID NOT IN (SELECT CounselID FROM counseltable
    WHERE IPlitID = #url.IPlitID#)
    ORDER BY Counsel
</cfquery>

<script>

function lookupAjax(){
    var oSuggest = $("#getOC")[0].autocompleter;

    oSuggest.findValue();

    return false;
}

$("#getOC").autocomplete("data/getOC.cfm", { autofill:true, extraParams:{iplitid:<cfoutput>#url.iplitid#</cfoutput>}, selectFirst:true,onFindValue:findValue,formatItem:formatItem,cellSeparator:"^" });

</script>

<!--- Autocomplete BEGIN --->

              <label for="getOC">Autosuggest Opposing Counsel<br /><input type="text" id="getOC" value="" /></label><br style="clear:both;" />

  <!--- Autocomplete END --->

My question is how do I pass along the law firm name and ID to a Text box and then take what is in the txt box (law firm name and ID) and save it back to the Database.

If you need more information, please ask.

Thank you,


Ashish Vohra

    This topic has been closed for replies.

    1 reply

    Participant
    February 15, 2010

    Wanted to add this. This comes from the "data/getOC.cfm" file:

    <cfsetting enablecfoutputonly="true">
    <cfparam name="q" default="" />
    <cfquery name="GetOC" datasource="datasourcename">
        SELECT  *  FROM table
        WHERE CounselID NOT IN (SELECT CounselID FROM tbl_counsel
        WHERE IPlitID = #url.IPlitID#)
        AND LName LIKE <cfqueryparam value="#lCase(URL.q)#%" cfsqltype="cf_sql_varchar" /> OR FName LIKE <cfqueryparam value="#lCase(URL.q)#%" cfsqltype="cf_sql_varchar" /> OR Counsel LIKE <cfqueryparam value="#lCase(URL.q)#%" cfsqltype="cf_sql_varchar" />
        ORDER BY Counsel
    </cfquery>


    <cfoutput query="GetOC">
    #GetOC.Counsel# | #GetOC.lname#, #GetOC.fname#^#GetOC.CounselID##chr(10)#
    </cfoutput>

    Inspiring
    February 23, 2010

    Antonio,

    I found myself in the same situation - my solution was to roll my own autosuggest solution using JQuery to retrieve the autosuggest records as a data structure, instead of just simple values.  Craig Kaminsky pointed me in the direction of Learning JQuery 1.3 which (quite frankly) ROCKS.  He also was nice enough to post a proof of concept example in response to my question.  You can find the discussion here:

    http://forums.adobe.com/message/1927669#1927669

    Learning JQuery 1.3 has a chapter specifically dedicated to developing an autosuggest solution.  With a little modification it was not difficult to go from a simple data type to a 2d JSON data structure.

    Hope that helps!