Roel Veldhuizen
Roel Veldhuizen

Reputation: 4723

Key - Values with JQuery autocomplete plugin

Is the standard JQuery autocomplete able to get key-values instead of only keys or only values.

Forexample userIds and username.

1 - Roel Veldhuizen
2 - Pino Jansen
3 - Afred van Buren

Where the userId is the saved value but the username is the search value and the value which is showed to the user.

Current code:

<script>
                    <!--
                    $(document).ready(function() {
                        $("#creatorUserId").autocomplete("Gateway.php?action=UserAction&subAction=suggest");
                    });
                    -->
                    </script>           
<input type="text" name="creatorUserId" id="creatorUserId" value="3" size="40" />

Upvotes: 1

Views: 174

Answers (1)

Samich
Samich

Reputation: 30095

Check example on the offisial site: Remote JSONP datasource.

There you can find that JS objects are binded to autcomplete and you can use any property of this object. In your case you need to format objects with name and value and use value when you need.

Upvotes: 1

Related Questions