jQuery Show/hide select based on dropdown selection

Hi there,

I have the following select:

<select name="place">

                        <option value="place1">Place 1</option>

                        <option value="place2">Place 1</option>

                        <option value="place3">Place 1</option>

                        <option value="place4">Place 1</option>
</select>

What I would like to do is display another select dropdown if either option “place2”, “place3” or “place4” is selected.

How would I do this?

Thanks!

var correctPlaces = ['place2', 'place3', 'place4'];

$('select[name=place]').change(function(){
    $('select[name=other]').toggle(correctPlaces.indexOf($(this).val())>=0);
});	

Live demo: https://jsfiddle.net/h48v2756/

Hi,

Many thanks for the reply. That is great, but I was hoping to display a different drop down for each option.

For example, If place 2 is selected, it would display a dropdown called place-2-dropdown and If place 3 is selected, it would display a dropdown called place-3-dropdown etc. Is this possible?

Thanks,

Yep. https://jsfiddle.net/h48v2756/1/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.