title: How to get the selected value from dropdown list and past it to sql query
body: <p>i have two dropdown list box,first one is sales area contain different kind of alphabet which get from cookie,second dropdown staff name is to change according to the selected value from first dropdown. How can i manage to pass the selected option value to my sql query so that it can be change according to the selected sales area.
  <a href="https://i.stack.imgur.com/BN07F.png" rel="nofollow noreferrer">This is the results that i want to get</a> I insert my code to the snippet for easy to do edit and demonstration.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function fetch_select(val)
  {
   $.ajax({
   type: 'post',
   url: 'updateleave.php',
   data: {
    get_option:val
   },
   success: function (response) {
    document.getElementById("slct2").innerHTML=response; 
   }
   });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table &gt;
   &lt;tr&gt;
       
       &lt;td&gt;  Sales Area 
    &lt;select name="Area" id="area" &gt;
          &lt;?php
     
          $sarea = explode(",",$_COOKIE['cooAreaCode']);
          foreach($sarea as $item){
    
          ?&gt;
          &lt;option   value="&lt;?php echo strtolower($item); ?&gt;"&gt;&lt;?php echo $item; ?&gt;&lt;/option&gt;
    
          &lt;?php
    
          }
     
  
  
   
          ?&gt;
         
         &lt;/select &gt;
         &lt;/td&gt;
      &lt;?
          $var = $_POST['Area'];
     $sql = "SELECT  StaffName FROM tblStaff WHERE AreaCode= '$var'";
        $rs = odbc_exec($link,$sql);
    while ($row = odbc_fetch_array($rs)) {
     $porr[] = $row;
      }
      
     odbc_free_result($rs);   
    odbc_close($link); 
    ?&gt;
       &lt;td&gt;  Staff Name 
    &lt;select id="slct2"&gt;
      
          ?&gt;
         
         &lt;/select&gt;
      
         &lt;/td&gt;
      &lt;label class="form_field"&gt;Your selected &lt;span id="aggregator_name"&gt;&lt;/span&gt;&lt;/label&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>(updateleave.php)</p>
  
  <pre><code>if (isset($_POST['get_option'])) {
  </code></pre>
  
  <p>$item=$_POST['get_option'];</p>
  
  <pre><code>  $sql = "SELECT  StaffName FROM tblStaff WHERE AreaCode= '$item'";
    $rs = odbc_exec($link,$sql);
   while ($row = odbc_fetch_array($rs)) {
       $porr[] = $row;
     }
      for($i=0; $i &lt; count($porr);$i++) {
     echo "&lt;option  value="strtolower($porr[$i]['StaffName']);" &gt;" .$porr[$i]['StaffName']."&lt;/option&gt;";
    odbc_free_result($rs);   
   odbc_close($link); 
      }
  ?&gt;
  </code></pre>