Skip to main content
Known Participant
July 26, 2013
Question

autosuggest

  • July 26, 2013
  • 1 reply
  • 874 views

Hi,

I have two questions, hope anyone can assist me with?


1) I have the drop box is displayed the long list of city names and don't want user to scroll up and down to find the name.  Is there the way we can do autosuggest like on the cfinput tag to narrow down the list in cfselect?


2 )
<cfinput type="text" name="city" autosuggest="cfc:cfc.city.lookupName({cfautosuggestvalue})">
It works fine with autosuggest, but we can only search for one name, is there the way to search for mutitples?.  For example, if I star enter A in the text box, then it shows Arlington, Angleton,Alvin ..I want to be able to select both Arlington and  Angleton and pass them into arguments?
       

Thanks

    This topic has been closed for replies.

    1 reply

    vishu_13
    Inspiring
    July 26, 2013

    Hi

    Create a .cfc name it as autosuggest.cfc

    <cfcomponent output="false">

        <!--- Lookup used for auto suggest --->

        <cffunction name="findPark" access="remote" returntype="string">

            <cfargument name="search" type="any" required="false" default="">

           

            <!--- Define variables --->

            <cfset var local = {} />

           

            <!--- Query Location Table --->

            <cfquery name="local.query" datasource="cfdocexamples" >

                select        parkname

                from        parks

                where        parkname like <cfqueryparam cfsqltype="cf_sql_varchar" value="#ucase(arguments.search)#%" />

                order by    parkname

            </cfquery>

            <!--- And return it as a List --->

            <cfreturn valueList(local.query.parkname)>

        </cffunction>

    </cfcomponent>

    Now create a.cfm and name as demo.cfm

    <!--- A simple form for auto suggest --->

    <cfform action="autosuggest.cfm" method="post">

        Park Name:<br />

        <cfinput type="text" name="parkname" size="50" autosuggest="cfc:autosuggest.findPark({cfautosuggestvalue})" autosuggestminlength="1" maxresultsdisplayed="10" /><br /><br />

    </cfform>

    Place both of them in the webroot and run demo.cfm, you will get exactly the same results which you are looking for.

    Hope it helps

    Thanks

    VJ

    newcfAuthor
    Known Participant
    July 29, 2013

    yes it worked fine, but my question is can we do the same for text area instead of input filed?  OR can we select mutiple values from the autolist for input field?

    Thanks

    vishu_13
    Inspiring
    July 29, 2013

    I don't think so you can achieve the same for text area however I am not sure as I havenot used it.