title: php code to store id of selected value from autocomplete textbox
body: <p>below is my autocomplete textbox code..</p>
  
  <p>code is working fine..</p>
  
  <p><strong>But I also need to store id of selected value in hidden textbox ..</strong></p>
  
  <p>FOR EX = </p>
  
  <p>there are 2 values coming in my auto textbox </p>
  
  <pre><code>id   societyname
  7      raj
  15     lucky
  </code></pre>
  
  <p>ok if i select raj from above value then display id of raj ie : 7 in hidden textbox</p>
  
  <p>plz any one help me.</p>
  
  <p><strong>Autocomplete textbox</strong></p>
  
  <pre><code>&lt;input id="society_name" name="society"/&gt;
   &lt;input type="hidden" id="society_name" name="societyid"/&gt;
  </code></pre>
  
  <p><strong>In ajax.php</strong></p>
  
  <pre><code>if($_GET['type'] == 'society'){ 
      $result = mysql_query("SELECT society FROM societymaster where society LIKE '".strtoupper($_GET['name_startsWith'])."%'");  
      $data = array();
      while ($row = mysql_fetch_array($result)) {
          array_push($data, $row['society']); 
      }   
      echo json_encode($data);
  }
  </code></pre>
  
  <p><strong>auto.js</strong></p>
  
  <pre><code>$('#society_name').autocomplete({
                  source: function( request, response ) {
                      $.ajax({
                          url : 'ajax.php',
                          dataType: "json",
                          data: {
                             name_startsWith: request.term,
                             type: 'society'
                          },
                           success: function( data ) {
                               response( $.map( data, function( item ) {
                                  return {
                                      label: item,
                                      value: item
                                  }
                              }));
                          }
                      });
                  },
                  autoFocus: true,
                  minLength: 0        
                });
  </code></pre>