Skip to main content
Inspiring
December 23, 2011
Question

Autocomplete or Autosuggest passing an ID as the value, as CFSELECT can

  • December 23, 2011
  • 1 reply
  • 1409 views

I have Autosuggest or Autocomplete(are they the same thing?) working on one ColdFusion form where people register for an event by selecting their name from an input. In the past, I've used a CFSELECT which is dynamically populated from a CFQUERY array. Then, when the user clicks "Submit," the value that is passed is not the name, but the user ID, which is absolutely unique, in contrast to a name. So with a CFINPUT or INPUT field, what is passed is what the user entered, namely, the name selected. That isn't quite what I need. Is there a way to use Autosuggest so that a value from the database, other than the literal name that the user has selected in the form field, is what is passed to an action page, where I can do various queries based on a user ID? I haven't come across this in my Googling yet, and logically, it doesn't seem possible with a plain INPUT field. But is autosuggest a possibility with a CFSELECT field?

This topic has been closed for replies.

1 reply

Inspiring
December 24, 2011

What you can probably do is populate a hidden form field at the same time you populate the text box.

However:

1.  With autosuggest the user is free to reject all offerings and type whatever they want into the text box.

2. There is this little matter of duplicate names. 

Inspiring
December 24, 2011

Dan,

Thank you for your perspective. That does it! I had the same misgiving about duplicate names and users entering anything in the box, although

I hadn't thought of the hidden form field. So I think the wise move here is to stick with CFSELECT, which is tried and true.

Feliz navidad y feliz ano nuevo!

Inspiring
December 24, 2011

Using a cfselect does not necessarily solve the duplicate names problem.  How is the user supposed to know which one to pick?  Also, if you start to get too many records, the select will take a long time to load.