Skip navigation
jjsand28
Currently Being Moderated

autosuggest to poulate rest of form

Jun 17, 2011 2:43 AM

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
    </cfquery>
    <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)>
      </cfif>
    </cfloop>
    <cfreturn arr.retNames>
  </cffunction>

 

Thank you in advance.

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points