title: Get the value of selected dropdown to compare to another dropdown
body: <p>I have 2 dropdown, the branch dropdown gets app_cn from database. And the sem dropdown gets app_plan_no. But I need to get the value selected in branch dropdown to compare with value selected in sem dropdown.</p>
  
  <p>I saw this code but I don't have any idea how to do this</p>
  
  <pre><code>   &lt;?php
      $mysqli = new mysqli("localhost", "root", "", "app");
      $result = $mysqli-&gt;query("SELECT * FROM app GROUP BY app_cn ORDER BY app_cn");
      echo'&lt;select name="drop_1" id="drop_1"&gt;';
       while($row = $result-&gt;fetch_assoc())
          {
             echo '&lt;option value="'.$row['app_cn'].'"&gt;'.$row['app_cn'].'&lt;/option&gt;';
          }
  echo'&lt;/select&gt;';
  
  if($_GET['func'] == "drop_1" &amp;&amp; isset($_GET['func'])) {
     drop_1($_GET['drop_var']); 
  }
  
  function drop_1($drop_var)
  {
      $mysqli = new mysqli("localhost", "root", "", "app");
      $results = $mysqli-&gt;query("SELECT * FROM app WHERE app_cn='$drop_var' GROUP BY app_plan_no ORDER BY app_plan_no");
  
      echo '&lt;select name="tier_two" id="tier_two"&gt;
            &lt;option value=" " disabled="disabled" selected="selected"&gt;Choose one&lt;/option&gt;';
  
            while($drop_2 = $results-&gt;fetch_assoc())
              {
              if($drop_2['app_plan_no'] != '')
              {
                echo '&lt;option value="'.$drop_2['app_plan_no'].'"&gt;'.$drop_2['app_plan_no'].'&lt;/option&gt;';
              }
              }
  
  }
  echo'&lt;/select&gt;';
  ?&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $('#wait_1').hide();
      $('#drop_1').change(function(){
              if( $(this).val() == "ALL") {
              $("#wait_1").hide();
              $("#result_1").hide();
          }else{
        $('#wait_1').show();
        $('#result_1').hide();
        $.get("func.php", {
          func: "drop_1",
          drop_var: $('#drop_1').val()
        }, function(response){
          $('#result_1').fadeOut();
          setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
        });
        }
          return false;
      });
  });
  
  function finishAjax(id, response) {
    $('#wait_1').hide();
    $('#'+id).html(unescape(response));
    $('#'+id).fadeIn();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And this what I want to do <code>WHERE app_cn='$drop_var'</code></p>
  
  <p>My table</p>
  
  <pre><code>counter | app_cn   | app_plan_no 
  
  000004  |  comp1   |  1
  000172  |  comp1   |  1
  000007  |  comp1   |  2
  000005  |  comp2   |  1
  </code></pre>
  
  <p>And this is my select dropdown</p>
  
  <pre><code>&lt;select name="branch" id="branch" onchange="showCourses()"&gt;
  &lt;option value="ALL" selected='ALL'&gt;ALL&lt;/option&gt;
  &lt;?php
  $mysqli = new mysqli("localhost", "root", "", "app");
      $result = $mysqli-&gt;query("SELECT * FROM app GROUP BY app_cn ORDER BY app_cn");
       while($row = $result-&gt;fetch_assoc())
          {
             echo '&lt;option value="'.$row['app_cn'].'"&gt;'.$row['app_cn'].'&lt;/option&gt;';
          }?&gt;
  &lt;/select&gt;
  &lt;select name="sem" id="sem" onchange="showCourses()"&gt;
  &lt;?php
  
  $mysqli = new mysqli("localhost", "root", "", "app");
      $result = $mysqli-&gt;query("SELECT * FROM app GROUP BY app_plan_no ORDER BY app_plan_no");
       while($row = $result-&gt;fetch_assoc())
          {
             echo '&lt;option value="'.$row['app_plan_no'].'"&gt;'.$row['app_plan_no'].'&lt;/option&gt;';
          }
          ?&gt;
  &lt;/select&gt;
  </code></pre>