0

I have dropdown values. if i select one dropdown(CandidateFunctions) values, it will populate the another dropdown(PreferredFunctions). This is working good only. but when i select the CandidateFunctions in the second time it is not changing the value..

My code in jquery is

$(document).ready(function () {

                   $("#CandidateFunctions").change(function () {
                       if ($("#PreferredFunctions").val() == "" || $("#PreferredFunctions").val() == null) {
                           $("#PreferredFunctions").val($("#CandidateFunctions").val());
                       }
                   });
                });

how to populate the values even second time also? please help me...

Duk
  • 905
  • 5
  • 15
  • 34

2 Answers2

1

Like The code below should help u:

$("#dropdwon1").change(function(){
    $("#dropdwon2").val($(this).val());
});

working version here: http://jsfiddle.net/xkT3U/

codebreaker
  • 1,465
  • 1
  • 12
  • 18
0

Better way is use on method, and bind event on document not on selector, and let the framework to find the target and invoke function

$(document).ready(function () {
      $(document).on("change","#CandidateFunctions",function () {
      if ($("#PreferredFunctions").val() == "" || $("#PreferredFunctions").val() == null) {
            $("#PreferredFunctions").val($("#CandidateFunctions").val());
        }
     });
  });
A.T.
  • 24,694
  • 8
  • 47
  • 65