nbuytaert1 / apex-select2

Select lists in Oracle APEX as they should be
https://apex.oracle.com/pls/apex/f?p=64237:20
GNU General Public License v2.0
56 stars 18 forks source link

Unable to set value to Nth value in the list #121

Closed ScottHollows closed 4 years ago

ScottHollows commented 4 years ago

With a regular SELECT item (not Select2) it is possible to set the value of the item to the first value in the drop list

image

There are at least three ways to do this with a regular ApEx Select item, but none of these work with Select2

1) Javascript document.getElementById("P1234_MY_ITEM").selectedIndex = 0;

2) Javascript document.getElementById("P1234_MY_ITEM").options[0].selected = true;

3) Javascript JQuery $("P1234_MY_ITEM").get(0).selectedIndex = 0; For all of these, Ive tried with and without quotes "0" but no luck

Is there a way to do this with Select2 ?

nbuytaert1 commented 4 years ago

Your JavaScript statements are fine, but they need an extra line for Select2 to pick up the changed value. For example:

document.getElementById("P1234_MY_ITEM").selectedIndex = 0;
$("#P1234_MY_ITEM").trigger('change');
ScottHollows commented 4 years ago

I have verified that your solution works

Thank you

Closing