It's a little trickier than the title does it, but here are the basic business rules:
- There are three highlighted menus on the screen. pages, each of which is filled with the same parameters and values.
- There will always be three menu selections.
- There will always be the same number of options / values in each menu selection.
- Selecting a question from any of the menus will remove that question as an option from the other two menus.
- Re-selecting another question from any of the menus returns the question that was previously deleted from the other two menus in the index that was previously.
I tried this in several different ways, and what killed me is number 5. I know that it will not be inserted in the exact index, because some questions may have already been deleted, which will change the order of the index. This basically requires insertBefore or insertAfter, which puts it in the same "slot".
Even if you do not publish any code, some thoughts on how you could approach this would be extremely useful. The select menus and jQuery look something like this, but I have had many attempts at it in different ways:
JQuery
$(function() {
$(".questions").change(function() {
var t = this;
var s = $(t).find(":selected");
$(".questions").each(function(i) {
if (t != this) {
$(this).find("option[value=" + s.val() + "]").remove();
}
});
});
});
HTML:
<select name="select1" class="questions">
<option value="1">Please select an option...</option>
<option value="2">What is your favorite color?</option>
<option value="3">What is your pet name?</option>
<option value="4">How old are you?</option>
</select>
<select name="select2" class="questions">
<option value="1">Please select an option...</option>
<option value="2">What is your favorite color?</option>
<option value="3">What is your pet name?</option>
<option value="4">How old are you?</option>
</select>
<select name="select3" class="questions">
<option value="1">Please select an option...</option>
<option value="2">What is your favorite color?</option>
<option value="3">What is your pet name?</option>
<option value="4">How old are you?</option>
</select>
user4903
source
share