Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/220292-auto-suggest-submit-id-not-title/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.