I finally figured it out. For the record...

JS Data:
        var accounts = [
                { name: "Account One", id: "0001" },
                { name: "Account Two", id: "0002" },
                { name: "Account Three", id: "0003" },
                { name: "Account Four", id: "0004" },
                { name: "Account Five", id: "0005"}
        ];

JS Functions:
        $().ready(function() {
                $("#account").autocomplete(accounts, {
                        minChars: 0,
                        width: 500,
                        matchContains: true,
                        autoFill: false,
                        scrollHeight: 300,
                        scroll: true,
                        max: 25,
                        formatItem: function(row, i, max) {
                                return row.name;
                        },
                        formatMatch: function(row, i, max) {
                                return row.name;
                        },
                        formatResult: function(row) {
                                return row.name;
                        }
                });
                $("#account").result(function(event, data, formatted) {
                        $("#account_value").val(data["id"]);
                });
        });

XHTML:
        <input type="text" id="account" size="50" />
        <input type="hidden" id="account_value" name="account" value="" />

Reply via email to