Presto-X Posted November 30, 2010 Share Posted November 30, 2010 I’m having a developer help build a form with an auto suggest search field to search for a category, what I would like to know is, is it possible to display the category titles in the suggestion drop down and then when the form is submitted, submit the category ID, not the title that is displayed in the field? Also if anyone knows of a script that is already written that does this (submits ID instead of title) please let us know. Quote Link to comment https://forums.phpfreaks.com/topic/220292-auto-suggest-submit-id-not-title/ Share on other sites More sharing options...
Adam Posted November 30, 2010 Share Posted November 30, 2010 Yeah, that's perfectly possible. Are you using the jQuery auto-complete plug-in? I had to do something similar a few months back with it. Quote Link to comment https://forums.phpfreaks.com/topic/220292-auto-suggest-submit-id-not-title/#findComment-1141575 Share on other sites More sharing options...
haku Posted December 1, 2010 Share Posted December 1, 2010 As the autosuggest will display the text, you and store the ids with the value in a global array, and use that. For example: suggestValues = [] suggestValues['suggested this'] = 1; // the ID is 1 suggestValues['suggested that'] = 2; // the ID is 2 function getSuggestedValueID (suggestedValue) { return suggestValues[suggestedValue]; } Pass the value that the user submits into the getSuggestedValue function, and this will output the ID for that value. Quote Link to comment https://forums.phpfreaks.com/topic/220292-auto-suggest-submit-id-not-title/#findComment-1141704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.