title: Update the list automatically after selecting the option with JavaScript or jquery
body: <p>I want to update the list after choosing the option of another list</p>
  
  <p>HTML code</p>
  
  <pre><code>  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"&gt;
    &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.5/css/bootstrap-select.min.css"&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.5/js/bootstrap-select.min.js"&gt;&lt;/script&gt;
  
  &lt;form action="check-add.php" method="post"&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td align="center" height="60"&gt;students&lt;/span&gt;&lt;/td&gt;
  &lt;td align="center" height="60"&gt;&lt;select id="first-choice"&gt;
  &lt;option disabled selected&gt;select students&lt;/option&gt;
  &lt;option value="1"&gt;Mark&lt;/option&gt;
  &lt;option value="2"&gt;Makarious&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="center" height="60"&gt;subject&lt;/td&gt;
  &lt;td align="center" height="60"&gt;
   &lt;select class="selectpicker" data-style="btn-info" multiple data-max-options="7" data-live-search="true" id="second-choice"&gt;&lt;/select&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="center" height="100" colspan="2"&gt;
  &lt;input type="submit" class="but" name="save-students" value="add"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JavaScript code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $("#first-choice").change(function() {
  $("#second-choice").load("getter.php?choice=" + $("#first-choice").val());
  }).trigger("change");
  &lt;/script&gt;
  </code></pre>
  
  <p>getter.php file</p>
  
  <pre><code>&lt;?php
      @include("../include/config.php");
  
      $choice = @mysqli_real_escape_string($conn, $_GET['choice']);
      $result = @mysqli_query($conn,"SELECT * FROM subjects WHERE phases='".$choice."'");
      while($row = @mysqli_fetch_array($result, MYSQL_ASSOC)){
          echo '&lt;option value="'.$row['id'].'"&gt;'.$row['title'].'&lt;/option&gt;';
      }
  ?&gt;
  </code></pre>
  
  <p>After choosing variable in this list
  Does not update the second list
  It does not appear the options
  In the #second-choice</p>
  
  <p><strong>I want JavaScript code to update automatically for the second list, but after choosing the option from the first menu</strong></p>