title: How to get a select box to control another select box
body: <p>I can't find a nice way to defining this, so I was hoping someone could help.</p>
  
  <p>I have two select boxes (Division and Sub-Division).  When the user comes in, they only see the Division select box.  When they select a division, the sub-division select box appears under it and only shows items for that division.  Much like this.</p>
  
  <pre><code>&lt;select name="divisions"&gt;
  &lt;option value="1"&gt;Div1&lt;/option&gt;
  &lt;option value="2"&gt;Div2&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;select name="subdivisions"&gt;
  &lt;option value="1" division="1"&gt;Sub1&lt;/option&gt;
  &lt;option value="2" division="1"&gt;Sub2&lt;/option&gt;
  &lt;option value="3" division="2"&gt;Sub3&lt;/option&gt;
  &lt;option value="4" division="2"&gt;Sub3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>So, when I choose division 1, I should see the second select box pop up and only show Sub1 and Sub2 as options in that select box.  When I choose division 2, the second select box should only show Sub3 and Sub4.  I would like to know how I can do this using PHP and javascript easily.</p>
  
  <p>I am using codeigniter to code this page and I've already sent my view the Divisions and SubDivisions objects with the data I need to build the select boxes.  I don't know if I have to convert these objects to javascript or not, but I would like to avoid that if possible.  It sounds like it'll get too complicated to convert my object to javascript arrays and then populate the select box.</p>