Change drop down list values when another user makes a choice from another drop down list in the same form
<p>My question is: How can i change the options-values from one list according to what a user choose from another drop down list. My issue here is that these both lists must be populated with a query.</p>

<pre><code>&lt;label for="category"&gt;&lt;/label&gt;
          &lt;select name="category" id="category"&gt;
          &lt;option value="0" &gt;Choose Category&lt;/option&gt;


&lt;?php foreach(Categories::find_all() as $id) :?&gt;
        &lt;?php echo "&lt;option value=".$id-&gt;id ."&gt;". $id-&gt;cat_name."&lt;/option&gt;"; ?&gt;
        &lt;?php endforeach?&gt;
</code></pre>

<p></p>

<pre><code>&lt;label for="sub_category"&gt;&lt;/label&gt;
          &lt;select name="sub_category" id="sub_category"&gt;
          &lt;option value="0" &gt;Choose Sub Category&lt;/option&gt;



&lt;?php foreach(Categories_sub::find_by_cat_id(????) as $id) :?&gt;
    &lt;?php echo "&lt;option value=".$id-&gt;id ."&gt;". $id-&gt;cat_sub_name."&lt;/option&gt;"; ?&gt;
    &lt;?php endforeach?&gt;
</code></pre>

<p></p>
