Eric,
You need to use formatItem.

http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions

For example, let's assume that the JSON you are returning from your
server script looks like (taken from the example data):
[
        { name: "Peter Pan", to: "pe...@pan.de" },
        { name: "Molly", to: "mo...@yahoo.com" }
]

And you only want to display the 'name' part and use the 'to' part as
the value.

First change the formatItem to something like:
formatItem: function(row, i, max) {
                        return row.name;
                },

And change the formatMatch to something like:
                formatMatch: function(row, i, max) {
                        return row.name;
                }

Here's the modified code from the example that's included in the
plugin:
        $("#suggest13").autocomplete(emails, {
                minChars: 0,
                width: 310,
                matchContains: "word",
                autoFill: false,
                formatItem: function(row, i, max) {
                        return row.name;
                },
                formatMatch: function(row, i, max) {
                        return row.to;
                },
                formatResult: function(row) {
                        return row.to;
                }
        });

There are other ways to do what's shown above, but I think that's the
easiest.
hope that helps.
Chris

On Oct 5, 2:16 pm, benze <ebenza...@gmail.com> wrote:
> Hi,
>
> I'm trying to figure out how to use theautocompletejQuery plugin
> best to my needs.  I'm looking to replace a select box with 
> theAutocompleteplugin, but not quite sure how to accomplish this.
>
> In my select box, I have the option that is displayed is not the same
> as the data that is submitted.
> ex: <option value="123">This is Displayed </option>
>
> However, with theautocomplete, since it is using a textbox, the
> values that are displayed, are submitted.
>
> Do I have to hack around using hidden fields to accomplish this type
> of behaviour?
>
> Thanks,
>
> Eric

Reply via email to