title: How to Set & Get ID in JQuery Autocomplete
body: <p>Thanks for read my question.I am working on Mobile Application using PhoneGap.
  I am using HTML 5 database to store data.</p>
  <p>My one of the table is <code>Company</code> which have <code>com_id &amp; com_name</code>.
  I have create simple search textbox using <a href="http://jqueryui.com/autocomplete/#default" rel="nofollow noreferrer">this</a>.That's working properly with static &amp; dynamic array.</p>
  <p>Here is my bit of code which fetch records from database and set in <em>auto complete</em>.</p>
  <pre><code>function All_Company_QuerySuccess(tx, results) {
      console.log(&quot;Returned rows = &quot; + results.rows.length);
      var com_array = []; // init array
      //this will return user_id if user exist else return &quot;no user&quot;
      if (!results.rowsAffected) {
          for (var index = 0; index &lt; results.rows.length; index++) {
              var item = results.rows.item(index);
              var com_id = item.com_id; // company id
              var com_name = item.com_name; // company name 
              com_array.push(com_name) // add value into array
          }
          // assign drop down
          $(function () {
  
              $(&quot;#pur_com_text&quot;).autocomplete({
                  source: com_array,
                  select: function (event, ui) {
                      selected_company = ui.item.value;
                      alert(selected_company);
                  }
              });
          });
      }
  } 
  </code></pre>
  <p><strong>Html code</strong></p>
  <pre><code>&lt;div data-role=&quot;fieldcontain&quot;&gt;
  &lt;input name=&quot;&quot; id=&quot;pur_com_text&quot; placeholder=&quot;Search Company&quot; value=&quot;&quot; type=&quot;search&quot; onClick=&quot;Get_All_Company()&quot; /&gt;
  &lt;/div&gt;
  </code></pre>
  <p>While i will type in search box it will shows me company name.</p>
  <p><strong>Issue :</strong></p>
  <p>I want to get that selected <code>company ID (com_id)</code> for further task.I don't know how can i get that or what should i do for that.</p>
  <p>Please Guide me how to solve this issue.</p>