tags:

views:

49

answers:

3

Hello friends 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

+2  A: 
$('#IdOfYourDropDown').change(function(){
    if($(this).val() == 'Yes'){
        $('#IdOfYourDiv').show();
    }
    else{
        $('#IdOfYourDiv').hide();
    }
});
Patricia
and without jquery? :PI'd type out an answer but I don't think the asker will accept any answer anyway
Litso
@Litso: I guess the 'without jQuery' has like no interesst to the OP, only tagging `jQuery`.
jAndy
the question was tagged jQuery... so i gave a jQuery answer :)
Patricia
@patricia @jAndy haha, didn't notice that. Sorry :P
Litso
@Litso: ahhh so it was you who downvoted my answer?
Patricia
A: 
$('#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.

jAndy
A: 

Thank you patricia, very much appreceated. I don't know how to accept answer, pls anyone suggest me. The javascript version would be great for learning purpose but too much code i guess. Thanks

sagarmatha