Here i have three dropdown lists each contains same number of values.So the question is If value 'one' is selected from '#dropdownone'. it should not show value 'one' for the rest of the two dropdown menus. Also if some value is selected from '#dropdowntwo' it should not show the values in the dropdown for the other two elements list. same case for the '#dropdownthree'. But if other values are selected from the list. the previously selected values will show in the rest of the dropdown lists.
FIDDLE
HTML
<select id='dropdownone'></select>
<select id='dropdowntwo'></select>
<select id='dropdownthree'></select>
Javascript
var numbers = ['one', 'two', 'three', 'four', 'five'];
$.each(numbers, function( key, value ) {
if (key == 0) {
$("#dropdownone").append("<option selected='selected' value='"+key+"'>"+value+"</option>");
$("#dropdowntwo").append("<option value='"+key+"'>"+value+"</option>");
$("#dropdownthree").append("<option value='"+key+"'>"+value+"</option>");
} else if (key == 1) {
$("#dropdownone").append("<option value='"+key+"'>"+value+"</option>");
$("#dropdownthree").append("<option value='"+key+"'>"+value+"</option>");
$("#dropdowntwo").append("<option selected='selected' value='"+key+"'>"+value+"</option>");
} else if (key == 2) {
$("#dropdownone").append("<option value='"+key+"'>"+value+"</option>");
$("#dropdowntwo").append("<option value='"+key+"'>"+value+"</option>");
$("#dropdownthree").append("<option selected='selected' value='"+key+"'>"+value+"</option>");
} else {
$("#dropdownone").append("<option value='"+key+"'>"+value+"</option>");
$("#dropdowntwo").append("<option value='"+key+"'>"+value+"</option>");
$("#dropdownthree").append("<option value='"+key+"'>"+value+"</option>");
}
});
Note: I need the function works in onchange event
for example
first time value selection if value 'one' is selected from '#dropdownone' it should not show the one value in '#dropdowntwo' & '#dropdownthree'.
second time value selection if value 'two' is selected from '#dropdownone' it should not show the value two in '#dropdowntwo' & '#dropdownthree'. but the prevoiusly selected value 'one' should show for the two dropdown elements
third time value selection if again value 'one' is selected from '#dropdownone' it should not show the value in '#dropdowntwo' & '#dropdownthree'.
But if other values are selected from the list. the previously selected values will show in the rest of the dropdown lists.?optionusing jquery?