title: dynamic multiple select for category/subcategory/keywords
body: <p>I am battling with this for few weeks now and can't get it work.
  In my database I have Single Table Inherited for Category Subcategory and Keywords. They are in tree structure through parent_id. </p>
  
  <p>The chosen script seem to work for each individual list. But I can't figure out how dynamically handle relationship between Parent and Children, so in Subcategories list would be available options that only belongs to my pre selected Category(one or few).</p>
  
  <p>Here what I have in my script.</p>
  
  <pre><code>jQuery(function($){
  $(".chosen-input").chosen().trigger("liszt:updated");
  $(".schosen-input").chosen().change(function(){
    var subcategories = $("companies_categories").children('select:visible').val();
    });
  $(".kchosen-input").chosen().change(function(){
    var keywords = $("companies_subcategories").children('select:visible').val();
    });
  });
  </code></pre>
  
  <p>My Form Looks fine.</p>
  
  <p><img src="https://i.stack.imgur.com/YWRqa.png" alt="This is my forms"></p>
  
  <p>Chosen script works.</p>
  
  <p><img src="https://i.stack.imgur.com/mvJkU.png" alt="enter image description here"></p>
  
  <p><strong>Filtering shows me whole list of Subcategories. But I need only children of perviously preselected Category.</strong> </p>
  
  <p><img src="https://i.stack.imgur.com/lLIj5.png" alt="enter image description here"></p>
  
  <p>Same with Keywords.</p>
  
  <p><img src="https://i.stack.imgur.com/Ro8RR.png" alt="enter image description here"></p>
  
  <p>HTML</p>
  
  <pre><code> &lt;fieldset class="inputs"&gt;&lt;legend&gt;&lt;span&gt;Categories&lt;/span&gt;&lt;/legend&gt;&lt;ol&gt;
   &lt;li class="select input optional" id="company_categories_input"&gt;
  &lt;input name="company[category_ids][]" type="hidden" value="" /&gt;
  &lt;label class=" label" for="company_category_ids"&gt;Categories&lt;/label&gt;
  &lt;input name="company[category_ids][]" type="hidden" value="" /&gt;
  &lt;select class="chosen-input" id="company_category_ids" multiple="multiple" 
  name="company[category_ids][]"  style="width: 700px;"&gt;
  
  
  &lt;option value="50"&gt;Apparel &amp;amp; Luggage&lt;/option&gt;
  &lt;option value="126"&gt;Automotive, RV, Cycling &amp;amp; Other Transportation&lt;/option&gt;
  &lt;option value="180"&gt;Baby, Toddler &amp;amp; Children&lt;/option&gt;
  &lt;option value="208"&gt;Beauty &amp;amp; Personal Care&lt;/option&gt;
  &lt;option value="288"&gt;Chemicals&lt;/option&gt;
  &lt;option value="331"&gt;Arts, Crafts, Hobbies &amp;amp; Fabrics&lt;/option&gt;
  &lt;option value="392"&gt;Electronics &amp;amp; Computers&lt;/option&gt;
  30 More records
   &lt;option value="461"&gt;Fitness &amp;amp; Sports&lt;/option&gt;&lt;/select&gt;&lt;/li&gt;
  
  &lt;li class="select input optional" id="company_subcategories_input"&gt;
  &lt;input name="company[subcategory_ids][]" type="hidden" value="" /&gt;
  &lt;label class=" label" for="company_subcategory_ids"&gt;Subcategories&lt;/label&gt;
  &lt;input name="company[subcategory_ids][]" type="hidden" value="" /&gt;
  &lt;select class="schosen-input" id="company_subcategory_ids" multiple="multiple"
  name="company[subcategory_ids][]" style="width: 700px;"&gt;
  
  &lt;option value="13"&gt;Small Kitchen Appliances&lt;/option&gt;
  &lt;option value="24"&gt;Laundry &amp;amp; Garment Care&lt;/option&gt;
  &lt;option value="28"&gt;Home Appliances&lt;/option&gt;
  &lt;option value="36"&gt;Commercial Grade Appliances&lt;/option&gt;
  &lt;option value="46"&gt;Appliance Cleaners&lt;/option&gt;
  Few more hundreds records
  &lt;option value="1811"&gt;Management of Bank Holding Companies &amp;amp; 
  Corporate Offices&lt;/option&gt;&lt;/select&gt;&lt;/li&gt;
  
  &lt;li class="select input optional" id="company_keywords_input"&gt;
  &lt;input name="company[keyword_ids][]" type="hidden" value="" /&gt;
  &lt;label class=" label" for="company_keyword_ids"&gt;Keywords&lt;/label&gt;
  &lt;input name="company[keyword_ids][]" type="hidden" value="" /&gt;
  &lt;select class="schosen-input" id="company_keyword_ids" multiple="multiple"
  name="company[keyword_ids][]" style="width: 700px;"&gt;
  
  &lt;option value="5"&gt;Ranges - Range Hoods&lt;/option&gt;
  &lt;option value="6"&gt;Ovens - Warming Drawers&lt;/option&gt;
  &lt;option value="7"&gt;Stoves - Cooktops&lt;/option&gt;
  &lt;option value="8"&gt;Dishwashers&lt;/option&gt;
  &lt;option value="9"&gt;Disposers - Trash Compactors&lt;/option&gt;
  Over 1000 more records
  &lt;option value="1179"&gt;Soil Amendment - Soil Preperation - Composting - 
  Garden Care - Nursery Products&lt;/option&gt;&lt;/select&gt;
  &lt;/li&gt;&lt;/ol&gt;&lt;/fieldset&gt;
  </code></pre>
  
  <p>Seems like I am missing alot. But don't know where to begin with this.</p>