> Try $("#suggest2+pk").val( data[1] ) or $(this).next().val( data[i] );
> And first check if the "#suggest2+pk" selector really selects your
> hidden input.
>

This technique worked great for populating a hidden field.  I am
trying to use the same technique to add an option to a select control
instead of setting the value attribute of a hidden field.  As a test I
am sending the value to an alert, which I expected to display the text
value returned from the autocomplete field.  Instead I am seeing
[object Object] returned.  I don't understand why I am not getting the
values I want returned.

$("#suggest2").result(function(event, data, formatted) {
        $("#unitid").value = $(this).next().val(data[1]); // this works for
populating a hidden field
       // these 2 vars to capture the values so I pass them to the
addOption function
        var tVal = $(this).next().val(data[0]); // set this in preparation to
pass text value in option
        var sVal = $(this).next().val(data[1]); // set this in prepartion to
pass id value in option
        alert(tVal) // this displays as [object Object]
});

I also tried passing $(this).next().val(data[0]) directly and still
get the [object Object] reference.

Jeff


Reply via email to