I'm trying to use jQuery autocomplete.result()
to get the ID associated with the name value the user selects. Here's the script:
<script type="text/javascript">
$("#DonorName").autocomplete($('#ajaxListMatchingDonorNamesUrl').val())
.result(function (evt, data, formatted) {
$("#SelectedDonorId").val(data[1]);
});
</script>
And here's the HTML I'm trying to use it from:
Html.TextBox("DonorName", "")
<input
id="ajaxListMatchingDonorNamesUrl"
type="hidden"
value="path" />
<input type="hidden"
name="SelectedDonorId" />
Firebug shows the correct values in data[] (e.g., [0]=Name and [1]=ID). However, when the form POSTs, the SelectedDonorId
value is empty.
I tried removing the from the html, but that simply removes the key from the param collection after the POST.
What am I missing? Thx.