title: How to redirect to another page with jQuery Autocomplete depending on the id of the selection
body: <p>I am new to all this but im here to learn. I'm sure this is not a big problem, but i have been trying for hours and couldnt find the solution. So i hope someone here can help me out.</p>
  
  <p>What im trying to do is, retrieve and show some data from my table(city names), and then when someone selects a city, it redirects him to another page which is populated with some data  depending on the cityid of the chosen city. </p>
  
  <p>I tried to solve this in 2 ways. Ill post the code for both so if anyone knows the answer for either i would be gratefull and ill explain what the problem is.</p>
  
  <p>1) First try:</p>
  
  <p>This is my script for autocomplete :</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
      var availableTags = [
      { label: "&lt;?php echo $row_rsCityCountry['cityName']; ?&gt;,
      &lt;?php echo $row_rsCityCountry['countryName']; ?&gt;",
      data: "questionnaire.php?cityid=&lt;?php echo $row_rsCityCountry['cityid']; ?&gt;" }];
  
      $( "#rightSearchField" ).autocomplete({
          source: function(request, response) {
              var results = $.ui.autocomplete.filter(availableTags, request.term);
              response(results.slice(0, 10));
          },
          select: function( event, ui ) { 
              window.location.href = ui.item.data;
          }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The problem here is, my autocomplete does retrieve city and country name from database, but it only shows 1 row(record). It is not possible for me to make it a repeat region so I'm not sure how to make it show all . Also, important thing, it does recognize the cityid and when I click on the record it does go to the questionnaire page and shows the id of the selected record. So that part is working as intended.</p>
  
  <p>2)Second try:</p>
  
  <p>This is my script for autocomplete :</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
  
      $("#auto").autocomplete({ 
          source: "search.php", 
      select: function( event, ui ) { 
          window.location.href = "questionnaire.php?cityid=&lt;?php echo 
              $row_Recordset1['cityid']; ?&gt;";
          } 
  });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The problem with the second try is, it shows all the records now, but when i click on any of them it redirects me to the questionnaire page but it doesn't recognize the id of the clicked record. </p>
  
  <p>I know this was long, but i hope someone can help me with my problem. If I didn't explain it well, please tell me and I'll try my best to do it again. Thank you for your time.</p>