I have two dropdowns (which are using Chosen.js). The second dropdown displays custom categories:
<script type="text/javascript">
jQuery(document).ready(function($) {
$('select[name="post_type"]').change(function (event) {
if ($('select[name="post_type"]').val() === 'test') {
$('select[name="second_dropwdown"]').html("<option>Sorry, no options</option>");
$('#second_dropwdown').prop('disabled', true).trigger('chosen:updated');
}else{
$('#second_dropwdown').prop('disabled', false).trigger('chosen:updated');
}
});
});
</script>
If I choose "test" in the first dropdown, the second dropdown becomes disabled and shows "Sorry, no options". My problem is that when you then choose anything other than "test" afterwards, the second dropdown doesn't populate with the categories again. How would I go about doing that? ie, revert back to the options it had before:
$('#second_dropwdown').prop('disabled', true).trigger('chosen:updated');
Thanks in advance!!