Response title
This is preview!




class jsonReturn { public int value { get; set; } public string label { get; set; } } @Html.HiddenFor(m => m.SupplierTypeID) @Html.TextBoxFor(m => m.SupplierBranchName) @Html.HiddenFor(m => m.SupplierID) <script> $("#SupplierBranchName") .autocomplete({ source: function (request, response) { $.getJSON('@Url.Action("SupplierSearch")', { term: request.term, supplierTypeID: $('#SupplierTypeID').val() }, response ) } }); </Script> $("#SupplierBranchName") .autocomplete({ source: function (request, response) { $.getJSON('@Url.Action("SupplierSearch")', { term: request.term, supplierTypeID: $('#SupplierTypeID').val() }, response ) }, select: function (event, ui) { $(this).val(ui.item.label); $("#SupplierID").val(ui.item.value); // alert(ui.item.value); // alert(ui.item.label); // alert(this.value); // alert($("#SupplierID").val); } });
SupplierBranchName, and the contents of "value" are set as the
value of an input box with id=SupplierID
If the value of "label" is initially set properly, and then
changes, my hunch is you have some code somewhere else that
fires on change or blur and messes things up. Autocomplete
is not doing that.
© 2012 jQuery Foundation
Sponsored by
and others.
