title: Selectbox Laravel select onChange
body: <p>I would like to filter some results depending on my selectbox <code>poule_id</code> in Laravel. For example, if I select <code>poule_id = 1</code>, it should display (on click) all teams that are in the <code>poule_id = 1</code>.</p>
  
  <p>Anyone knows a good practice or a quick tutorial to achieve that? I would like to use jQuery for this.</p>
  
  <p>Currently, I have: </p>
  
  <blockquote>
    <p>Route::get('search/equipes' , 'CompetitionController@searchEquipes');</p>
  </blockquote>
  
  <p>My controller : </p>
  
  <pre><code>public function searchEquipes(Request $request)
      {
          $equipes = [];
  
          if($request-&gt;has('poule_id')){
              $equipes = EquipePoule::where('poule_id',$request-&gt;poule_id)
                  -&gt;get();
          }
  
  
          return response()-&gt;json(['equipes' =&gt; $equipes]);
      }
  
  
  
   &lt;div class="tab-pane" id="tab_2"&gt;
      &lt;div class="col-md-4 pull-right"&gt;
  
  
   &lt;select id="poule"&gt;
  @foreach($select_poules as $select_poule)
  &lt;option value="{{$select_poule-&gt;id}}"&gt;{{$select_poule-&gt;lb_poule}}&lt;/option&gt;
  @endforeach
  &lt;/select&gt;
          &lt;/div&gt;
          &lt;table class="table table-striped"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Club&lt;/th&gt;
                      &lt;th&gt;Nom de l'équipe&lt;/th&gt;
                      &lt;th&gt;Bonus(+/-)&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  @foreach($equipes as $equipe)
                  &lt;tr&gt;
                      &lt;td&gt;&lt;a href="{!! route('club.show', $equipe-&gt;equipe-&gt;structure-&gt;id) !!}"&gt;{{$equipe-&gt;equipe-&gt;structure-&gt;nom_structure}}&lt;/a&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;a href="{!! route('equipe.show', $equipe-&gt;equipe-&gt;id) !!}"&gt;{{$equipe-&gt;equipe-&gt;lb_equipe}}&lt;/a&gt;&lt;/td&gt;
                      &lt;td&gt;{!! Form::text('nb_bonus') !!}&lt;/td&gt;
                  &lt;/tr&gt;
                  @endforeach
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  
  
  &lt;script src="https://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          $(document).on('change', '#poule', function() {
  
              $.ajaxSetup({
                  headers: {
                      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                  }
              });
  
              $.ajax({
                  type: 'GET',
                  dataType: "json",
                  url : '/search/equipes',
                  data : {poule_id : $('#poule').val()},
                  success:function(data){
  
                      $('table tbody').empty().append(data.equipes);
  
                  },
                  timeout:10000
              });
  
          });
      &lt;/script&gt;
  </code></pre>