I have two different select menus (menu A and menu B). Both with the same values. How do I make sure selected menu A value is not equal to menu B value onsubmit? Would be cool if the selected menu A becomes non selectable on menu B?
Any suggestions?
I have two different select menus (menu A and menu B). Both with the same values. How do I make sure selected menu A value is not equal to menu B value onsubmit? Would be cool if the selected menu A becomes non selectable on menu B?
Any suggestions?
On
The simplest vay to check it on submit is:
$("#list1").val() !== $("#list2").val();
And if you want to make it non selectable you could something like this:
$("#list1").change(function(){
$("#list2 [value=" + $(this).val() + "]").attr("disabled","disabled");
})
To erase previous disabled options:
$("#list1").change(function(){
$("#list2").find("option").each(function(){
$(this).removeAttr("disabled");
});
$("#list2 [value=" + $(this).val() + "]").attr("disabled","disabled");
})
Use the following code to diable the option in the second select
demo