📋Improving UX in Oracle APEX: Copy Select List Values to clipboard Without Plugins

🚩Introduction 

  • In Oracle Application Express (APEX), Select List items are commonly used to provide predefined values and ensure data consistency. However, APEX does not offer a built-in declarative option to copy the selected value directly using the mouse. Since it is rendered as a dropdown list, the displayed value cannot be highlighted and copied like a standard text field.

  • This limitation can be resolved by creating a custom Dynamic Action using JavaScript. The selected value can be captured programmatically and copied to the clipboard without using plugins. This approach improves usability while maintaining the standard behavior of the Select List component.

📑Why It Is Essential to Enable Copy Functionality for Select List

In Oracle Application Express (APEX), Select List values often contain important reference data that users may need to reuse. Since the dropdown content cannot be directly highlighted and copied, it can affect the user experience.

Enabling copy functionality improves efficiency, reduces manual retyping errors, and enhances overall user experience without modifying the standard Select List behavior

  • Enable users to copy the selected value from a Select List easily

  • Avoid manual retyping and reduce data entry errors

  • Trigger additional actions based on the copied value if needed

  • Improve overall user efficiency and workflow within the page

  • Maintain the standard Select List behavior without using plugins

👉 Steps to Enable Copy Functionality for a Select List

We can enable users to copy the selected value from a Select List by creating a custom Dynamic Action in APEX without any plugins. We can see how to achieve this in the following steps.

Step 1: 

In the page designer, create a page item and select the type as select list and under the list of values, select any type (eg. SQL Query) and write the sql query. 



/* Sample SQL Query for the LOV */

SELECT 'One' d, 1 r FROM dual
UNION
SELECT 'Two' d, 2 r FROM dual
UNION
SELECT 'Three' d, 3 r FROM dual

Step 2: 

In the Page Item, under the Post Text property, copy and paste the HTML element to create the copy icon. 

<span id = "copyIcon" class = "fa fa-clipboard" style = "cursor:pointer" onclick = "copytoclipboard()"></span>

Step 3: 

Create the javascript function copytoclipboard() in the Function and Global Variable Declaration section and copy the CSS code in the inline css section.

/* Function & Global Variable Declaration Section */ 

function copytoclipboard() { // replace with your select list page item name below (P19_SELECT)
    var selectedValue = apex.item("P19_SELECT").displayValueFor($v("P19_SELECT")); 
    if(selectedValue != "") {
        navigator.clipboard.writeText(selectedValue);
        apex.message.showPageSuccess("Copied");
    } else {
        alert("Please select any value to copy...");
    }
}
/* Css */

/* Replace with your select list page item name (change the highlighted word #P19_SELECT) */

#P19_SELECT_CONTAINER .t-Form-itemText--post {
    padding: 5px;
    border: 1px solid #eee;
    background-color: #eee;
}

Step 4: 

Now save the page and run the application, select any value from the select list and click on the copy icon to copy the content (display value) of the selected value in the select list and it will be saved in the clipboard.




🔥 Conclusion

Thus, enabling copy functionality for a Select List can be achieved by creating a custom Dynamic Action in APEX without any plugins. This allows developers to capture the selected value, copy it to the clipboard, and trigger additional actions if needed, improving usability and providing a more efficient, user-friendly interface without relying on external tools

Comments

Popular posts from this blog

🔍 Extending Smart Search Filter for Multiple Regions

💡 Designing Dynamic QuickPicks in Oracle APEX

📌Track Active Tab switch in Region Display Selector without any plugins