I have these three select boxes below, I want when first select box empty, hide second and third select boxes, When first select box contains custom-category show second select box, When first select box contains custom-tag show third select box, When first select box contains custom-category and custom-tag in same time show second and third select boxes
I try to this jquery code but not work for all case that described above
$('.field-content-multiple select').change(function() {
$(this).find('option:selected').each(function() {
if($(this).attr('value') == 'custom-category') {
$('p.field-custom-category').show();
$('p.field-custom-tag').hide();
} else if($(this).attr('value') == 'custom-tag') {
$('p.field-custom-tag').show();
$('p.field-custom-category').hide();
} else {
$('p.field-custom-category').hide();
$('p.field-custom-tag').hide();
}
});
}).change();
these are the three select boxes
<p class="field-content-multiple description description-wide">
<select name="menu-item-content-multiple[<?php echo $item_id; ?>][]" id="edit-menu-item-content-multiple-<?php echo $item_id; ?>" class="widefat code edit-menu-item-content-multiple bsnselect" multiple>
<?php foreach (self::$YPE_multiple as $key => $value): ?>
<option value="<?php echo $key; ?>" <?php echo selected(in_array($key, $item->content_multiple)); ?>><?php echo $value;?> </option>
<?php endforeach ?>
</select>
</p>
<p class="field-custom-category description description-wide">
<label for="edit-menu-item-custom-category-<?php echo $item_id; ?>">
<?php _e( 'Select specific categories' ); ?><br />
<select name="menu-item-custom-category[<?php echo $item_id; ?>][]" id="edit-menu-item-custom-category-<?php echo $item_id; ?>" class="widefat code edit-menu-item-custom-category bsnselect" multiple>
<?php
$YPE_cats = get_categories();
foreach ($YPE_cats as $YPE_cat) { ?>
<option value="<?php echo $YPE_cat->slug; ?>" <?php echo selected(in_array($YPE_cat->slug, $item->custom_category)); ?>><?php echo $YPE_cat->name;?></option><?php
}
?>
</select>
</label>
</p>
<p class="field-custom-tag description description-wide">
<label for="edit-menu-item-custom-tag-<?php echo $item_id; ?>">
<?php _e( 'Select specific tags' ); ?><br />
<select name="menu-item-custom-tag[<?php echo $item_id; ?>][]" id="edit- menu-item-custom-tag-<?php echo $item_id; ?>" class="widefat code edit-menu- item-custom-tag bsnselect" multiple>
<?php
$YPE_tags = get_tags();
foreach ($YPE_tags as $YPE_tag) { ?>
<option value="<?php echo $YPE_tag->slug; ?>" <?php echo selected(in_array($YPE_tag->slug, $item->custom_tag)); ?>><?php echo $YPE_tag->name;?></option><?php
}
?>
</select>
</label>
</p>