title: JQUERY Populate "Select" options dynamically based on input from another select element
body: <p>I would like to change the options in a select element based on what i select in another select element (dropdown box).</p>
  
  <p>I have two select boxes (RUNS and SAMPLES) on my PHP page. What i intend to do is to change options in the second select box based on a query that is performed against a database using the option selected in first select box.</p>
  
  <p>I have a table in my database that connects "SAMPLES" to "RUNS". The first select box is populated by a set of 'RUNS' on page load. I would like the 'SAMPLES' that belong to the selected RUN to populate in the SAMPLES box.</p>
  
  <p>The HTML would be something like </p>
  
  <pre><code>&lt;select name='run_id' id='run_id&gt;
      &lt;option value='1'&gt;RUN 1&lt;/option&gt;
      &lt;option value='2'&gt;RUN 2&lt;/option&gt;
      &lt;option value='4'&gt;RUN 3&lt;/option&gt;
      &lt;option value='5'&gt;RUN 4&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The backend table "sample_runs" has columns run_id and sample_name. I have a PHP script as follows,</p>
  
  <pre><code>&lt;?php
  mysql_connect("localhost","uname","pwwd");
  mysql_select_db("dbname");
  $run_id = $_GET['run_id'];
  $sql = "select distinct sample_name from samples where run_id = '$run_id'";
  $rsd = mysql_query($sql);
  while($rs = mysql_fetch_array($rsd)){
      echo '&lt;option value='.$rs['sample_name'],'&gt;'.$rs['sample_name']."&lt;/option&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>I can modify the PHP script (easy part), but can someone share some code with me on how to populate the sample name options based on the run_id selected in the RUNS box.</p>
  
  <p>Greatly appreciate the help.</p>