title: Filter select-options through another select-option value
body: <p>My target is to filter <code>&lt;select name="team"&gt;</code> by using a JS function from <code>&lt;select name="unit"&gt;</code>. Team is a many-to-one relationship with Unit so filtering it would be much more safer option. I've list down the tables and my test codes below:</p>
  
  <p><br></p>
  
  <p>Team-Unit pivot table</p>
  
  <p><code>-------------------</code></p>
  
  <p><code>Team --------- Unit</code></p>
  
  <p><code>A ------------- 1</code></p>
  
  <p><code>B ------------- 1</code></p>
  
  <p><code>C ------------- 1</code></p>
  
  <p><code>D ------------- 2</code></p>
  
  <p><code>E ------------- 2</code></p>
  
  <p><code>F ------------- 3</code></p>
  
  <p><code>-------------------</code></p>
  
  <p><br></p>
  
  <pre><code>&lt;select name="unit" class="form-control" id="unit" onchange="refreshTeam()" required /&gt;
      &lt;option value="" selected disabled&gt;SELECT UNIT&lt;/option&gt;
      @foreach ($units as $unit)
          &lt;option value="{{$unit-&gt;id}}"&gt;{{ $unit-&gt;title }}&lt;/option&gt;
      @endforeach
  &lt;/select&gt;
  
  
  &lt;select name="team" class="form-control" id="team" required /&gt;
      &lt;option value="" selected disabled&gt;SELECT TEAM&lt;/option&gt;
      @foreach ($teams as $team)
          &lt;option value="{{$team-&gt;id}}"&gt;{{ $team-&gt;title }}&lt;/option&gt;
      @endforeach
   &lt;/select&gt;
  </code></pre>
  
  <p><br>
  Here's my try on refreshTeam(), but I'm pretty sure this is wrong or needs improvement</p>
  
  <pre><code>function refreshTeam() {
          var team = document.getElementById("team");
          var unit = document.getElementById("unit");
  
          &lt;?php
              $unit = 'document.getElementById("unit").value';
  
              $team_unit = \DB::table('teams')
                              -&gt;leftJoin('team_unit', 'teams.id', '=', 'team_unit.team_id')
                              -&gt;leftJoin('units', 'units.id', '=', 'team_unit.unit_id')
                              -&gt;select('teams.*')
                              -&gt;where($unit, '=', 'team_unit.unit_id')
                              -&gt;get();
              dd($team_unit);
          ?&gt;
      }
  </code></pre>