Oracle APEX - automatically select a single item in a cascading popup LOV

581 Views Asked by At

I have two cascading popup LOVs on my page P2_LOV1 and P2_LOV2

P2_LOV2 gets populated based on a query and the value selected in P2_LOV1. What I want is if there is only one value populated in P2_LOV2, set it as a selected value. How can I do that?

1

There are 1 best solutions below

3
On

You could create an on change dynamic action with a client side condition of

$('#P2_LOV2 option').length == 2

The length may be 1 or 2, depending on if you have a null option.

If true, set the value. Again, the numeric may be 1 or 0, depending on null selection.

('#P2_LOV2').prop('selectedIndex', 1)

But if you don't have a null selection, this would automatically set to first value, right?