I had great help with an earlier post but have yet to be able to modify it to my needs.
I have four drop down lists that are used so people can rank their favorite items.
When an item is selected in the first drop down list, it then disappears from the 2nd, 3rd and 4th lists.
Then when an item is chosen from the 2nd list, it disappears from the 3rd and 4th, etc...
That part works great.
However, I have two other drop down lists in this form that I do not want affected by this feature.
Unfortunately I have not figured out how to do this yet.
Any help is appreciated.
The code is below, care of Godsbest. Thanks again!
Peter T
- <form>
- <select id=i1>
- </select>
- <select id=i2>
- </select>
- <select id=i3>
- </select>
- <select id=i4>
- </select>
- </form>
- var txt = 'Select One';
- var options = ['One','Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten'];
- var used = [];
- $(function() {
- $('select').each(function() {
- $this = $(this);
- $('<option/>').text( txt ).appendTo( $this );
- $.each(options,function(i,v) {
- $('<option/>').text( v ).appendTo( $this );
- });
- });
- $('select').on('change',function() {
- used = $.map( $('select').filter(function() { return $(this).val() !== txt; }), function(v,i) { return v.value; });
- $('select').each(function(i,v) {
- var $this = $(this);
- var val = $this.val();
- $this.html('');
- $('<option/>').text( txt ).appendTo( $this );
- $.each(options,function(i,v) {
- ($.inArray(v, used) > -1 && (v !== val) ) || $('<option/>').text( v ).appendTo( $this );
- });
- $this.val( val );
- });
- });
- });