title: Jquery autocomplete
body: <p>I have mysql table like this:</p>
  
  <pre><code> country   | city_accented |   latitude   |    longitude |
   ---------------------------------------------------------
   australia |    sydney     | -33.8833333  |  151.2166667 |
      USA    |    dallas     |  35.3163889  |  -81.1763889 |
  </code></pre>
  
  <p>I'm using jquery autocomplete to get country names in form text field.
  How can I post with this Jquery function all other data from database (latitude, longitude, ...) to my form and use it there like hidden field ?</p>
  
  <p>The Jquery code:</p>
  
  <pre><code>function lookup(inputString) {
  if(inputString.length == 0) {
      // Hide the suggestion box.
      $('#suggestions').hide();
  } else {
      $.post("rpc.php", {queryString: ""+inputString+""}, function(data){
          if(data.length &gt;0) {
              $('#suggestions').show();
              $('#autoSuggestionsList').html(data);
          }
      });
  }
  } // lookup
  
  function fill(thisValue) {
  $('#inputString').val(thisValue);
  $('#suggestions').hide();
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input size="30" id="inputString" onkeyup="lookup(this.value);" type="text" /&gt;
  &lt;div class="suggestionsBox" id="suggestions" style="display: none;"&gt;
  &lt;div class="suggestionList" id="autoSuggestionsList"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>if(isset($_POST['queryString'])) {
  $queryString = $_POST['queryString'];       
  if(strlen($queryString) &gt;0) {
  $query = "SELECT * FROM cities WHERE city_accented LIKE '$queryString%' LIMIT 10";
  $result = mysql_query($query) or die("There is an error in database");
  while($row = mysql_fetch_array($result)){
  echo '&lt;li onClick="fill(\''.$row['city_accented'].'\');"&gt;'.$row['city_accented'].','.$row['country'].' &lt;/li&gt;';                                        
  }
  }
  }
  </code></pre>