Possible Duplicate:
jQuery / Programmatically Select an Option in Select Box
I was wondering, is it possible to select an option from a selectbox/combobox directly from jQuery. For example I want to select the option with the value 5 in a select with values from 1 to 10.
The only solution I can think of is to remove all options and recreate them with the right selected value, but that's a bit unefficient.
You also can remove the duplicates from the table list firstly, then create the drop down list. Select the column range you want to use in the table, the press Ctrl + C to copy it, and place it to another position by pressing Ctrl + V. Then keep selecting the list, click Data > Remove Duplicates.
The below codes works fine for two dropdowns, but not for more than 2. var $select = $("select[id$='go']"); $select. change(function() { $select . not(this) .
Just treat the select box as you would any other input element:
$("#MySelectBox").val("5");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With