title: Autocomplete in two input boxes? - javascript
body: <p>Hi i am trying to find out how to use my javascript code for two input boxes.  the data its grabing and the URL is using C# code but that should not matter.  Please help me with my autocomplete..</p>
  
  <p>Here is a test page of it in action</p>
  
  <p><a href="http://www.bivar.com/test.aspx" rel="nofollow">http://www.bivar.com/test.aspx</a></p>
  
  <p>Here is the code i am using for the javascript.</p>
  
  <pre><code>&lt;link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"&gt;&lt;/script&gt;  
  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          SearchText();
      });
      function SearchText() {
          $(".autosuggest").autocomplete({
               select:function(event, ui){
                window.location.href = '/Products/ProductInfoCenter.aspx?partnum=' + ui.item.value;
             },
              source: function (request, response) {
                  $.ajax({
                      type: "POST",
                      contentType: "application/json; charset=utf-8",
                      url: "/test.aspx/GetAutoCompleteData",
                      data: "{'PartNumber':'" + document.getElementById('txtPartNum').value + "'}",
                      dataType: "json",
                      success: function (data) {
                         response(data.d);
                      },
                      error: function (result) {
                          alert(err.message);
                      }
                  });
              }
          });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here are the two input boxes</p>
  
  <pre><code>   &lt;input type="text" id="txtPartNum" class="autosuggest" /&gt;
        &lt;input type="text" id="txtPartNum2" class="autosuggest" /&gt;
  </code></pre>
  
  <p>Thank you and please help.</p>