ktm
ktm

Reputation: 6085

How to show div upon clicking drop down box

I have a drop down box with yes and no values. By default it's set to 'No' however when we select the value of yes another div should appear. Please help

Upvotes: 0

Views: 570

Answers (2)

jAndy
jAndy

Reputation: 236022

$('#my_dropdown_id').bind('change', function(){
   switch($(this).val().toLowerCase()){
      case 'yes':{
          $('#my_show_id').show();
          break;
      }
      case 'no':{
          $('#my_show_id').hide();
          break;
      }
   }
});

You can extend that switch statement with any other value you might want to test for.

Upvotes: 0

Patricia
Patricia

Reputation: 7802

$('#IdOfYourDropDown').change(function(){
    if($(this).val() == 'Yes'){
        $('#IdOfYourDiv').show();
    }
    else{
        $('#IdOfYourDiv').hide();
    }
});

Upvotes: 2

Related Questions