auto filter and autocomplete

auto filter and autocomplete

Hi , 
 I need to filter per country first through dropdown select by country, then autosuggest/autocomplete on  the input textbox the companies under the countries selected. 

My question is  : How do I pass the variable from dropdown? 
Here are by codes below :

1st page (index)

  1. //dropdown 
  2.   <select name="f_country_id" class="form-control" id="f_country_id">
  3.    <option value="?cid=0&code=0" >-- Select Country --</option>
  4. <?php
  5. while($country = $sql_getCountries->fetch_assoc()){
  6. echo '<option ';
  7. if($country['id'] == $_GET['cid']){
  8. echo ' selected ';
  9. }
  10. echo 'value="?cid='.$country['id']'.'">'.$country['d_name'].'</option>';
  11. }
  12. ?>
  13.   </select> 

  14. <input type='text' name='d_name' value='' class='auto form-control' id="d_name"  placeholder="Name of Company/Establishment" >

  15. <!--- start here Autoload ////////// --->
  16. <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  17. <script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>
  18. <script type="text/javascript">
  19. $(function() {

  20. //autocomplete
  21. $(".auto").autocomplete({
  22. source: "auto_search.php" ,
  23. //minLength: 1
  24. });

  25. });
  26. </script>
  27. <!--- End here Autoload Scripts ////////// --->

2nd page (auto_search.php)
  1. if (isset($_GET['term'])){
  2. $return_arr = array();

  3. try {
  4.     $conn = new PDO("mysql:host=".DB_SERVER.";dbname=".DB_NAME, DB_USER, DB_PASSWORD);
  5.     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  6. $stmt = $conn->prepare("SELECT a.* FROM tb_company_establishment a  WHERE a.d_name LIKE :term");
  7.     $stmt->execute(array('term' => '%'.$_GET['term'].'%'));
  8.     
  9.     while($row = $stmt->fetch()) {
  10.         $return_arr[] =  $row['d_name'];
  11.     }

  12. } catch(PDOException $e) {
  13.     echo 'ERROR: ' . $e->getMessage();
  14. }


  15.     /* Toss back results as json encoded array. */
  16.     echo json_encode($return_arr);
  17. }
If only i can pass from the dropdown country variable to auto_search page then it can solve the problem.

Hope you can help me, im not used to jquery or javascript.

Thanks in advance