Making DropDownLists depend on each other Making DropDownLists depend on each other json json

Making DropDownLists depend on each other


I have an approach using JQuery, Check this example:http://jsfiddle.net/vt3Ma/4/

using focus() event will restore the current option value and text in 2 hidden fields

$('.ddl').focus(function(){$("#oldValue").val($(this).val());$("#oldText").val($("option:selected",$(this)).text());

});

then on change() event:-

1- will add the old changed option of the dropdown list to the other dropdown lists as the previous selected option became available now to choose.

$(this).prepend("<option value='"+$("#oldValue").val()+"'>"+$("#oldText").val()+"</option>");

2- will remove the new selected option from all other dropdown lists

$("option[value='" + current.val() + "']",$(this)).remove();