title: JavaScript in OSClass to show subcategory after parent is invalid in Firefox
body: <p>I'm using OSClass to build a site which will be holding several classified ads. Unfortunately some scripts don't work well with Firefox/IE so I need to track those errors down.</p>
  
  <p>The script is supposed to be like this:</p>
  
  <ol>
  <li>You choose category for your ad</li>
  <li>When you've chosen the category, the script checks for sub-categories and will add another box where you choose your sub-category.</li>
  </ol>
  
  <p>Here's the .js file:</p>
  
  <pre><code>var is_loading = true ;
  
  function fill_subcategory_select ( id ) {
  var category    = $("select.category") ;
  var subcategory = $("select.subcategory") ;
  
  // reset subcategory select
  subcategory.html("") ;
  
  console.log(twitter_theme.categories["id_" + id]) ;
  // check that the category has subcategories
  if( typeof twitter_theme.categories["id_" + id] === "undefined" ) {
      console.log("[fill_subcategory_select] hide subcategory") ;
      subcategory.append( $("&lt;option&gt;").attr('value', id) ) ;
      subcategory.css("display", "none") ;
      $("select.subcategory").trigger('change') ;
      return true;
  }
  
  subcategory.html()
  subcategory.append( $("&lt;option&gt;").attr('value', id).html(twitter_theme.text_select_subcategory) ) ;
  $.each(twitter_theme.categories["id_" + id], function(key, value) {
      console.log("[fill_subcategory_select] subcategory { id: " + value.id + ", slug: " + value.slug + ", name: " + value.name + " }") ;
      subcategory.append( $("&lt;option&gt;").attr('value', value.id).html(value.name) ) ;
  }) ;
  subcategory.css("display", "") ;
  return true;
  }
  </code></pre>
  
  <p>And here's from the actual form:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          twitter_theme.text_select_subcategory = "&lt;?php _e('Select a subcategory...', 'twitter_bootstrap') ; ?&gt;" ;
          twitter_theme.category_selected_id    = "&lt;?php echo item_selected_category_id() ; ?&gt;" ;
          twitter_theme.subcategory_selected_id = "&lt;?php echo item_selected_subcategory_id() ; ?&gt;" ;
  &lt;/script&gt;
  
  &lt;!-- category input --&gt;
  &lt;div class="clearfix"&gt;
  &lt;label&gt;&lt;?php _e('Category', 'twitter_bootstrap') ; ?&gt;&lt;/label&gt;
  &lt;div class="input"&gt;
  &lt;?php item_category_select( __('Select a category', 'twitter_bootstrap') ) ; ?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;!-- category input end --&gt;
  </code></pre>
  
  <p>What happens in Firefox is that when you choose a category the sub-category list won't show at all, which destroys the functionality of the register form because it gives the error message: "Invalid category".</p>