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 <kevin.mccorm...@cox.net> 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.

Reply via email to