0

I have 2 selects (a,b). Same data in both select. I want that when I choose an option in one of them, the same option disapear in the second one. If a reselect an other option, the one tha disapeared should reappears

tx

IsraGab
  • 3,819
  • 3
  • 20
  • 38
  • 4
    Do you have any code that you could show us? What have you tried? – Joshua M Jun 03 '13 at 10:45
  • That is not a very clear question. Try to show us some code/progress, be more code-specific in general. – Petr Čihula Jun 03 '13 at 10:45
  • why you want to do that? choosing multiple item in select? if yes use ` – ncm Jun 03 '13 at 10:45
  • are the options in the same order? – Spokey Jun 03 '13 at 10:45
  • i have seen this question so many times... – A. Wolff Jun 03 '13 at 10:49
  • I've found an answere for my question [here][1] Sorry!! [1]: http://stackoverflow.com/questions/4076770/getting-value-of-select-dropdown-before-change – IsraGab Jun 03 '13 at 10:57

1 Answers1

1

check here http://jsfiddle.net/RTzwL/

html

<select id="first">
    <option value="india">India</option>
    <option value="usa">USA</option>
    <option value="japan">Japan</option>
    <option value="australia">Australia</option>
</select>

<select id="second">
    <option value="india">India</option>
    <option value="usa">USA</option>
    <option value="japan">Japan</option>
    <option value="australia">Australia</option>
</select>

Javascript

$('select').change(function() {
    $(this).siblings('select').find('option').attr({disabled:false});
   var thisIndex = parseInt($(this)[0].selectedIndex)+1;
    $(this).siblings('select').find('option:nth-child('+thisIndex+')').attr({disabled:true});
});
Manish Jangir
  • 519
  • 3
  • 9