我通过在同一个字段中获取更多值来做到这一点。这是代码
.autocomplete(
{
source: function (request, response) {
$.ajax(
{
contentType: "application/json; charset=utf-8",
url: "../svc/SearchService.svc/GetMatchingVehiclesInfo",
data: "VehicleSearchName=" + $("#" + name).val(),
type: "GET",
dataType: "json",
success: function (data) {
response($.map(data.GetMatchingVehiclesInfoResult, function (value, key) {
return {
label: value.Name, //vehicle name
//below i combined multiple values into same field
value: value.ID + '#' + value.BodyType + '#' + value.FuelType + '#' + value.Seats
};
}));
},
error: function (result) {
alert("Error");
}
});
},
search: function () {
// custom minLength
var term = extractLast(this.value);
if (term.length < 1) {
return false;
}
},
focus: function () {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
this.value = ui.item.value;
$("#" + name).val(ui.item.label);
//here i extracted the value using split
$("#<%=hdnVehicle.ClientID%>").val(ui.item.value.split('#')[0]);
$("#<%=ddlFueltype.ClientID%>").value = ui.item.value.split('#')[2];
return false;
}
但即使我得到了价值,dropdownlist(ddlFueltype)
价值也不会改变。我试图弄清楚。