I am trying to develop a feature which involves 2 select list items.
Flow goes something like this,
- There are two list items (identical) with the same list items
- When I select an option from
Main Tagslist, the same option inSub Tagslist should get disabled. For example, If I selectTag 1from theMain Tagslist thenTag 1from theSub Tagslist should get disabled. (Toggle effect: when I select other options from the 1st list, then previously disabled item should b enabled) Sub Tagslist is multiple selection. Here selected values gets displad nex to it as a tags with delete tag option on it (Which is working in my code). But When user change the option fromMain Tagslist and the same thing is already been displayed here as aSelected tagssection then it should get removed fromselected tagssection andSub Tagslist (Which is disable at this point) as well.
Basic idea is not to have same option under both Main Tags and Sub Tags
Hope my question is clear.
Here is my current code,
$(function () {
$("#tagSel").change(function () {
$this = $(this);
$("#tags").append('<span id="' + $this.val() + '"> ' + $this.find('option:selected').text() + ' <a href="#">×</a></span>');
$this.find('option:selected').prop("disabled", true);
});
$("#tags").on("click", "span a", function () {
$("#tagSel option[value='" + $(this).parent().attr("id") + "']").prop('disabled',null);
$(this).parent().remove();
$("#tagSel_main").append('<i ></i>')
});
});