I've gotten the AutoCompleter by Jörn Zaefferer at
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete
working for one textbox on my page.  I'm now trying to add another.
The query works fine and it displays the data in the popup, but I get
an error when I select something.  I'm trying to take some of the
returned data and fill in some fields.  It's in relation to the
txtCompany textbox (the txtItem textbox is what is working fine and
filling in other data).  I'm still very new with JQuery and I'm
reading the new Learning JQuery book, but this seems fairly complex
right now.  Does anyone see any mistakes here:

$().ready(function() {

// For the txtItem textbox - works fine.
        function findValueCallback(event, data, formatted) {

                $("#ItmDesc").html(data[1]);
                $("#OnHandQty").html(data[2]);
                $("#Price").html(data[3]);

        }

// For the txtCompany textbox - does not work.
        function findValueCallback2(event, data, formatted) {

                $("#txtAddress1").html(data[1]);

        }

        function formatItem(row) {
                return row[0] + " - " + row[1];
        }

        function formatResult(row) {
                return row[0];
        }

        function formatBillTo(row) {
                return row[0];
        }

        function formatBillToResult(row) {
                return row[0];
        }

// For the txtItem textbox - works fine.
        $("#txtItem").autocomplete("ItemQuery.acm", {
                minChars: 3,
                delay: 150,
                width: 260,
                formatItem: formatItem,
                formatResult: formatResult,
                selectFirst: false,
                extraParams: {
                        CustNo: "123456"
                }
        });

// For the txtCompany textbox - query works, returned data is display,
can't get findValueCallback2 to work, it seems
        $("#txtCompany").autocomplete("BillToQuery.acm", {
                minChars: 3,
                delay: 150,
                width: 260,
                formatItem: formatBillTo,
                formatResult: formatBillToResult,
                selectFirst: false
        });

        $("#txtItem").result(findValueCallback).next().click(function() {
                $(this).prev().search();
        });
        $("#txtItem").result(function(event, data, formatted) {
                $(this).find("..+/input").val(data[1]);
        });
        $("#txtCompany").result(findValueCallback2).next().click(function() {
                $(this).prev().search();
        });
        $("#txtCompany").result(function(event, data, formatted) {
                $(this).find("..+/input").val(data[1]);
        });
});

Reply via email to