0

Suppose I have a dropdown select option like below:

 <form>
    <select name="option" >
                <option value="">Select a Value:</option>
                <option value="1">Option 1</option>
                <option value="2">Option 2</option>

    </select>
</form>

When any user Selects the Option 1 I want to display the following dropdown select beside it instantly

 <select name="name" >
                <option value="">Select a person:</option>
                <option value="john">john</option>
                <option value="Micheal">Micheal</option>

    </select>

Or, if any user Selects the Option 2 I want to display the following dropdown select beside it instantly

 <select name="class" >
                <option value="">Select a person:</option>
                <option value="Class 1">Class 1</option>
                <option value="Class 2">Class 2</option>

    </select>

Would you please kindly show me how to do this? I am using Codeigniter.

2
  • The two possible select menus, are they dynamic or static? If static, the answers will do, otherwise I guess you have to write your own functions. But still take the answers as a point to start from Commented Nov 1, 2011 at 21:53
  • You can also use the cascadeFrom functionality. Here is an example of it. demos.telerik.com/kendo-ui/dropdownlist/cascadingdropdownlist Commented Jan 21, 2016 at 15:31

2 Answers 2

2
$('select[name="option"]').change(function(){
    $('.hidden').hide();
    if(this.value == 1){
        $('select[name="name"]').toggle();
    }
    else if(this.value == 2){
        $('select[name="class"]').toggle();
    }
});

Fiddle: http://jsfiddle.net/maniator/Z6Upj/

Sign up to request clarification or add additional context in comments.

Comments

0

Give this a shot:

$(function(){
    $("select[name='option']").change(function(e){
        if ($(this).val() == "1")
            $("select[name='name']").show();
    });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.