Standard practices with auto-completing form fields?

I have a data that involves text and an index number from the database, and it is the index number that is used when the form is submitted, but, populating the text field with the index number is not user friendly. :slight_smile:

So, let’s say I have a customer name “Fred” (the text), and in the database, Fred’s customer id number is 2.

I type in “F-r-e” and Fred pops up. I click it, and…

With an auto-complete, the text should fill in the text field, but where do you put the database index number that points to the record from which the text is taken, or that you want to manipulate?

Do you put it in a hidden field, and then when the form is submitted, use the hidden field, ignoring the text field?
Do you create a custom attribute in the text field input where you place the index number?

Yes, that’s the best way.

Thank you!