Ajax Autocomplete field: display one value, but use another?
I've got an autocompleter in a CakePHP app that provides a dropdown list of neighborhoods to attach to a place. I'm pulling from a table 'neighborhoods' with name and id fields. I want the user to see the name of the neighborhood,开发者_如何转开发 and I want the app to see the id of the neighborhood and insert it into the places table. How can I make this happen?
Another way of doing this would be to storing the id. Then when a user presses submit you replace the input field's value with your stored value.
assign the correct (hidden) value to a hidden input field
This type of functionality is normally achieved with a combobox, which is like an autocomplete, with an underlying select
elememt, see here
精彩评论