With jquery autocomplete I have a hidden input field to store ID because the name gets inputted into the autocomplete field on select.
Like this:
$("#Clients").result(function (event, data, formatted) {
if (data) {
$("#ClientID").val(data["client_ClientNumber"]);
if (data["ClientName"] && data["client_address1"] && data["client_postcode"] && data["client_postname"]) {
$("#ClientDetails").html(
"<li class=\"clientNumber\">Client ID: " + data["client_ClientNumber"] + "</li>" +
"<li>" + data["ClientName"] + "</li>" +
"<li>" + data["client_address1"] + "</li>" +
"<li>" + data["client_postcode"] + data["client_postname"] + "</li>"
);
}
}
This is my HTML:
<div id="ClientSelectionPlaceholder">
<h3>Client</h3>
<%=Html.TextBox("Clients", null, new { @class = "clientsDropDown" })%>
<%=Html.Hidden("ClientID", null, new { disabled = true}) %>
</div>
The problem is that this hidden ClientID field is not posting back nor it does serialize with jquery.serialize(). It is always missing. But as far as I can tell my code looks fine.