title: Getting the selected value of jQuery autocomplete
body: <p>I have a form and it can have multiple jQuery autocompletes. When the form is submitted I want to get the selected values in the autocompletes, dump the values into a hidden text field and submit to the server.</p>
  
  <p>I can't seem to find any info on how to do this.  My code is below which works fine and binds to all textfields with the class autocomplete. Any ideas on this?</p>
  
  <pre><code>$(".autocomplete").autocomplete({
              autoFocus: true,
              source: function(request, response) {
                  $.ajax({
                      url: "@Url.Action("SearchEmployees", "ProjectBase")",
                      minLength: 3,
                      dataType: "json",
                      type: "GET",
                      data: { term: request.term },
                      success: function(data) {
                          response($.map(data, function(item) {
                              return {
                                  label: item.Fullname,
                                  value: item.EmployeeId
                              };
                          }));
                      },
                      error: function(xhr, textStatus, errorThrown) {
                          alert("error: " + errorThrown);
                      }
                  });
              },
              select: function(event, ui) {
                  event.preventDefault();
                  $(this).val(ui.item.label);
              },
              change: function (event, ui) {
                  alert("change: " + (ui.item ? ui.item.label : "&lt;no item&gt;"));
              }
          });
  </code></pre>