title: POST or GET selected value from select option before submit (same page)
body: <p>I have done searching this question here but there is no suitable answer for my problem. So to be more specific, I have 2 select option which is floor and room. Both selection displayed based on database. So is there a syntax that can get the selected floor id so I can do my query to display the specific room for the selected floor before submit? Here's my code :</p>
  
  <pre><code>&lt;form name="form" method="POST"&gt;        
      &lt;div class="form-group"&gt;
          &lt;div&gt;&lt;label&gt;Floor Name&lt;/label&gt;&lt;/div&gt;
              &lt;select class="form-control" id="floorid" name="existfloorname"&gt;
                  &lt;option&gt;None&lt;/option&gt;
              &lt;?php 
                  $result = $conn-&gt;query("select * from floors");
                  while ($row = $result-&gt;fetch_assoc()) 
                  {
                      ?&gt;&lt;option id="&lt;?php echo $row['floorid'];?&gt;" value="&lt;?php echo $row['floorname']; ?&gt;"&gt;&lt;?php echo $row['floorname']; ?&gt;&lt;/option&gt;&lt;?php
                  }               
              ?&gt;
              &lt;/select&gt;
      &lt;/div&gt;
  
  
      &lt;div class="form-group"&gt;
          &lt;div&gt;&lt;label&gt;Room Name&lt;/label&gt;&lt;/div&gt;
              &lt;select class="form-control" name="existroomname"&gt;
                  &lt;option&gt;None&lt;/option&gt;
              &lt;?php 
                  $result = $conn-&gt;query("select * from rooms where floorid = '".GETSELECTEDFLOORID."'");
                  while ($row = $result-&gt;fetch_assoc()) 
                  {
                      ?&gt;&lt;option value="&lt;?php echo $row['roomname']; ?&gt;"&gt;&lt;?php echo $row['roomname']; ?&gt;&lt;/option&gt;&lt;?php
                  }
              ?&gt;
              &lt;/select&gt;
      &lt;/div&gt;
      &lt;input type="submit" name="delete" value="Delete"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/MllL4.png" rel="nofollow noreferrer">This is how the form looks like</a></p>