Press "Enter" to skip to content

Oracle Apex: Get Display Value from Select List

In this tutorial, you will learn how to get display value from the Select List in Oracle Apex.

Usually, when we get the value using PL/SQL V() or binding methods (:), then we get the return value from the Select List.

But if you want to get the display value from the Select List, then you have to use the JavaScript API method displayValueFor() with apex.item namespace.

Method displayValueFor() returns the display value of the selected element on behalf of the return value.

Meaning to get the display value from the Select List, you have to pass the return value as an argument to the displayValueFor() method.

Getting Display Value from The Select List in Oracle Apex

For example, we have a Select List item P2_PRODUCT_LIST based on the following query:

Select product_name d, id r 
   from eba_cust_products
order by product_name;

In this case, the Select List P2_PRODUCT_LIST will display the product name and will return the value product id.

First, we will see how to get the returned value from the P2_PRODUCT_LIST using the JavaScript, because this is also needed to get the display value.

Get Return Value from Select List Using JavaScript

apex.item('P2_PRODUCT_LIST').getValue();

The above JavaScript code will get the return value from the Select List P2_PRODUCT_LIST.

You can get this value into a variable or can show directly using the alert message. For example:

var retValue;
retValue = apex.item('P2_PRODUCT_LIST').getValue();
apex.message.alert(retValue);

Get Display Value from Select Using JavaScript

To get the display value of the selected element from P2_PRODUCT_LIST use the following code:

var retValue, displayValue;
retValue = apex.item('P2_PRODUCT_LIST').getValue();
displayValue = apex.item('P2_PRODUCT_LIST').displayValueFor(retValue);
apex.message.alert(displayValue);

Output

Get display value for selected element from select list in Oracle Apex.

Related tutorials:

Have you found the answer to your question? If not, you can discuss it with me in the comments section below or join my Q&A community OrclQA.com for developers and ask your question. It is FREE.

Vinish Kapoor

Follow

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. foxinfotech.in is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
MAHENDRA
MAHENDRA
6 months ago

Begin
  for i in (select EMPNO,ENAME,DEPTNO from emp_temp where VALID_DATA_YN = ‘Y’) 
  loop

    insert into emp(EMPNO,ENAME,DEPTNO)
    values (i.EMPNO,i.ENAME,i.DEPTNO) ;
    –insert into emp(EMPNO,ENAME,DEPTNO) values (9001,’mmp’,20);     
    –apex_util.set_session_state(‘P45_DATA_UPLOAD_VALIDATE_IMPORT’,’X’) ;
    –execute immediate (‘TRUNCATE TABLE EMP_TEMP’);
  end loop;
  commit;
end;

In above, I stored imported data in EMP_TEMP table
then validated VALID_DATA_YN = ‘Y’ means validate Data , ‘N’  means Invalid data.
now I going to click om Import Data to insert in EMP table
BUT NOT INSERTED RECORD INTO EMP TABLE ??

1) This is done through Dynamic Action — Plsql Code as above
2) Processing –> processes –> import data –> plsql code as above

Thanks

MAHENDRA

Roberto Párraga Zambrano
Roberto Párraga Zambrano
3 months ago

Hi, how to Get Display Value from PopUpLov List?Regards