0

I have two select boxes as below.

<select name="origin" id="s1" class="editable-select" style="width:330px;height:40px;">
  <option value=""></option>
  <option value="Bangalore">Bangalore (BLR)</option>
  <option value="Chennai">Chennai (MAA)</option>
  <option value="Goa">Goa (GOI)</option>
  <option value="Hyderabad">Hyderabad (HYD)</option>
  <option value="Kolkata">Kolkata (CCU)</option>
  <option value="Mumbai">Mumbai (BOM)</option>
  <option value="New Delhi">New Delhi (DEL)</option>
  <option value="Pune">Pune (PNQ)</option>
</select>


<select id="s2" class="editable-select" style="width:330px;height:40px;" name="destination">
  <option value=""></option>
  <option value="Bangalore">Bangalore (BLR)</option>
  <option value="Chennai">Chennai (MAA)</option>
  <option value="Goa">Goa (GOI)</option>
  <option value="Hyderabad">Hyderabad (HYD)</option>
  <option value="Kolkata">Kolkata (CCU)</option>
  <option value="Mumbai">Mumbai (BOM)</option>
  <option value="New Delhi">New Delhi (DEL)</option>
  <option value="Pune">Pune (PNQ)</option>
</select>

Now if I select or change a option in the select box "s1". Then Focus should be on select box "s2" and it should get open automatically.

I have tried with onChange and onFocus Functions. Then onChange any option in "S1" the focus is jumping to "S2" but the dropdown is nott opening. Please go through this jsfiddle link : http://jsfiddle.net/eQxAj

Thanks in advance, Shoba

drf
  • 8,461
  • 32
  • 50

2 Answers2

0

Its not possible to open Select Box using JavaScript

Sudz
  • 4,268
  • 2
  • 17
  • 26
0

I don't think that there is a way to programmitcally open a select menu with jQuery but this might be an alternative for you:

$('#s1').change(function() {
    $('#s2').focus();
    $('#s2').attr('size',9);
});

$('#s2').change(function() {
    $('#s2').attr('size',1);
});

$('#s2').focusout(function() {
    $('#s2').attr('size',1);
});

I took out your inline styles on the selects to make it easier to see the effect.

http://jsfiddle.net/9eJUz/

martincarlin87
  • 10,848
  • 24
  • 98
  • 145