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.
The script is supposed to be like this:
- You choose category for your ad
- When you've chosen the category, the script checks for sub-categories and will add another box where you choose your sub-category.
Here's the .js file:
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( $("<option>").attr('value', id) ) ;
subcategory.css("display", "none") ;
$("select.subcategory").trigger('change') ;
return true;
}
subcategory.html()
subcategory.append( $("<option>").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( $("<option>").attr('value', value.id).html(value.name) ) ;
}) ;
subcategory.css("display", "") ;
return true;
}
And here's from the actual form:
<script type="text/javascript">
twitter_theme.text_select_subcategory = "<?php _e('Select a subcategory...', 'twitter_bootstrap') ; ?>" ;
twitter_theme.category_selected_id = "<?php echo item_selected_category_id() ; ?>" ;
twitter_theme.subcategory_selected_id = "<?php echo item_selected_subcategory_id() ; ?>" ;
</script>
<!-- category input -->
<div class="clearfix">
<label><?php _e('Category', 'twitter_bootstrap') ; ?></label>
<div class="input">
<?php item_category_select( __('Select a category', 'twitter_bootstrap') ) ; ?>
</div>
</div>
<!-- category input end -->
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".