0 Replies Latest reply on Jun 17, 2011 2:43 AM by jjsand28

    autosuggest to poulate rest of form

    jjsand28 Level 1

      I have a rather simple form for a music venue. As the user types in the name it searches the database for a match. That works perfectly. What I'd like to do is fill in the rest of the fields with address,city,state etc.


      Right now the name works perfectly but for the rest I get the entire array. Before anything is entered it shows every listing in the database as a comma delimited string.


      Here are some snippets.


      <label for="locName">Location</label>
                  <cfinput name="locName" id="locName" type="text" value="#form.locName#" size="20" maxlength="100"
            autosuggest="CFC:calendarcfc.locations.ajaxlocs ({cfautosuggestvalue})" showAutosuggestLoadingIcon="true" />
                  <label for="locAddress">Address</label>
                  <cfinput name="locAddress" id="locAddress" type="text" value="#form.locAddress#" bind="CFC:calendarcfc.locations.ajaxlocs({locName})" bindonload="true"/>



      The cfc


        <cffunction name="ajaxlocs" access="remote" returntype="array">
            <cfargument name="suggestValue" required="true">
          <cfset arr.retNames = arrayNew(1)>
          <cfquery name="ajaxlocs">
            select * from eventlocations
          <cfloop query="ajaxLocs">
              <cfif FindNoCase(arguments.suggestValue,locName)>
                <cfset arrayAppend(arr.retNames,locName)>
                <cfset arrayAppend(arr.retNames,locAddress)>
                <cfset arrayAppend(arr.retNames,locCity)>
                <cfset arrayAppend(arr.retNames,locState)>
                <cfset arrayAppend(arr.retNames,locZip)>
                <cfset arrayAppend(arr.retNames,locPhone)>
                <cfset arrayAppend(arr.retNames,locSite)>
          <cfreturn arr.retNames>


      Thank you in advance.