[jQuery] Re: jQuery AutoComplete - how to post a variable if option is selected?
Solved my own problem. See solution here: http://groups.google.com/group/jquery-en/msg/89adfbd3e15fde09 on discussion: http://groups.google.com/group/jquery-en/browse_thread/thread/84950b404129b00b On Feb 6, 10:29 am, Han wrote: > James, that problem that you just described is the exact problem that > I am having. I can get the autocomplete plugin to update a hidden > input with an id value perfectly fine if the user selects a value from > the list and triggers the result() function, however I also need it to > clear the hidden input in every other case. Do you know how to > accomplish this, or what part of the autocomplete plugin code might be > relevant if I were to add something in? > > Thanks. > > On Feb 3, 6:00 pm, James wrote: > > > One way I can think of is that you make a JSON list that has an "id" > > and "name" pair. When an existing option is selected, using > > theAutocomplete'sresult() function, add the id's value to some JS > > variable. > > (result() > > function:http://docs.jquery.com/Plugins/Autocomplete/result#handler) > > > If it's typed in, the variable won't be set (because the result() > > function would not be triggered). > > > Then when the form is submitted, use the extraParams option to pass > > the id value of that JS variable. > > > You'd probably want to find a way to clear that JS variable also > > (probably through a typing event). There might be the possibility that > > someone selects from a list, the variable gets set, and decides to > > type his own name. But the variable is still set, which is incorrect. > > > On Feb 3, 12:19 pm, ripcurlksm wrote: > > > > I am using a jQueryAutoCompleteplugin which fills in text as you type. I > > > need to find a way when the page is submitted (submit.php) to determine if > > > the user choose a company from the list, or if they typed in their own > > > unique company. > > > > If an option is selected, can i have jQuery post an extra $_POST variable > > > like "new" or "existing" so I can pick it up on the submit.php page? Or > > > when > > > an option is selected, can I have .js write a hidden tag which contains > > > the > > > variable "existing"? > > > > Example: > > > [url]http://www.psylicyde.com/_old/autocomplete/[/url] > > > > Source Code: > > > [url]http://www.psylicyde.com/_old/autocomplete/autocomplete.zip[/url] > > > > The end goal here is to post a variable on the next page if the user > > > selected an option from theautocompletelist. > > > -- > > > View this message in > > > context:http://www.nabble.com/jQuery-AutoComplete---how-to-post-a-variable-if... > > > Sent from the jQuery General Discussion mailing list archive at > > > Nabble.com.
[jQuery] Re: jQuery AutoComplete - how to post a variable if option is selected?
James, that problem that you just described is the exact problem that I am having. I can get the autocomplete plugin to update a hidden input with an id value perfectly fine if the user selects a value from the list and triggers the result() function, however I also need it to clear the hidden input in every other case. Do you know how to accomplish this, or what part of the autocomplete plugin code might be relevant if I were to add something in? Thanks. On Feb 3, 6:00 pm, James wrote: > One way I can think of is that you make a JSON list that has an "id" > and "name" pair. When an existing option is selected, using > theAutocomplete'sresult() function, add the id's value to some JS > variable. > (result() function:http://docs.jquery.com/Plugins/Autocomplete/result#handler) > > If it's typed in, the variable won't be set (because the result() > function would not be triggered). > > Then when the form is submitted, use the extraParams option to pass > the id value of that JS variable. > > You'd probably want to find a way to clear that JS variable also > (probably through a typing event). There might be the possibility that > someone selects from a list, the variable gets set, and decides to > type his own name. But the variable is still set, which is incorrect. > > On Feb 3, 12:19 pm, ripcurlksm wrote: > > > I am using a jQueryAutoCompleteplugin which fills in text as you type. I > > need to find a way when the page is submitted (submit.php) to determine if > > the user choose a company from the list, or if they typed in their own > > unique company. > > > If an option is selected, can i have jQuery post an extra $_POST variable > > like "new" or "existing" so I can pick it up on the submit.php page? Or when > > an option is selected, can I have .js write a hidden tag which contains the > > variable "existing"? > > > Example: > > [url]http://www.psylicyde.com/_old/autocomplete/[/url] > > > Source Code: > > [url]http://www.psylicyde.com/_old/autocomplete/autocomplete.zip[/url] > > > The end goal here is to post a variable on the next page if the user > > selected an option from theautocompletelist. > > -- > > View this message in > > context:http://www.nabble.com/jQuery-AutoComplete---how-to-post-a-variable-if... > > Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: jQuery AutoComplete - how to post a variable if option is selected?
One way I can think of is that you make a JSON list that has an "id" and "name" pair. When an existing option is selected, using the Autocomplete's result() function, add the id's value to some JS variable. (result() function: http://docs.jquery.com/Plugins/Autocomplete/result#handler) If it's typed in, the variable won't be set (because the result() function would not be triggered). Then when the form is submitted, use the extraParams option to pass the id value of that JS variable. You'd probably want to find a way to clear that JS variable also (probably through a typing event). There might be the possibility that someone selects from a list, the variable gets set, and decides to type his own name. But the variable is still set, which is incorrect. On Feb 3, 12:19 pm, ripcurlksm wrote: > I am using a jQuery AutoComplete plugin which fills in text as you type. I > need to find a way when the page is submitted (submit.php) to determine if > the user choose a company from the list, or if they typed in their own > unique company. > > If an option is selected, can i have jQuery post an extra $_POST variable > like "new" or "existing" so I can pick it up on the submit.php page? Or when > an option is selected, can I have .js write a hidden tag which contains the > variable "existing"? > > Example: > [url]http://www.psylicyde.com/_old/autocomplete/[/url] > > Source Code: > [url]http://www.psylicyde.com/_old/autocomplete/autocomplete.zip[/url] > > The end goal here is to post a variable on the next page if the user > selected an option from the autocomplete list. > -- > View this message in > context:http://www.nabble.com/jQuery-AutoComplete---how-to-post-a-variable-if... > Sent from the jQuery General Discussion mailing list archive at Nabble.com.