0

I am having two dropdowns in my page.On change of my first dropdown i need to populate the array values into another dropdown.On every change it should change the values.Can u please help on this

user1799494
  • 27
  • 1
  • 5
  • See this may be help you http://stackoverflow.com/questions/9170453/display-dropdown-values-based-on-previous-dropdown – Hkachhia Dec 07 '12 at 09:12

1 Answers1

1

try following :

  $("#dropDown1").change(function(){
        var dp2Values = [1,2,3,4,5];
        $("option",$(this)).remove();
        $.each(dp2Values ,function(a,b){
             $("<option></option>").text(b).appendTo($("#dropDown2"));
        });
    });

if you'r data would depend on selected index use this to retrive index :

 $("#dropDown1").change(function(){
            var $index = $("option:selected",$(this));            
        });
Behnam Esmaili
  • 5,835
  • 6
  • 32
  • 63