In modern web applications, improving user experience and preventing unintended data loss is critical. One common requirement is to restrict users from navigating to other tabs once they start entering data in the current tab.
In this blog, weβll walk through a simple yet effective approach to disable inactive tabs dynamically using JavaScript in Oracle APEX.
π π Use Case
In one of our recent projects, the client required:
π When a user starts entering data in one tab (e.g., Department),
π All other tabs (e.g., Employee) should be disabled
This ensures:
- No accidental navigation
- No partial/inconsistent data entry
- Better focus and usability
π οΈ Technologies Used
- Oracle APEX
- JavaScript (for UI control)
βοΈ Step-by-Step Implementation
πΉ Step 1: Create Tabs Container
- Create a Static Content Region
- Name: R_TABS
- Template: Tabs Container
πΉ Step 2: Create Hidden Item
- Item Name: PXX_TAB_ACTIVE
- Type: Hidden
- Protection Level: Unrestricted
π This will track which tab is active
πΉ Step 3: Create Tab Regions
Under R_TABS, create two sub-regions:
π Department Tab
- Region Name: R_TAB_DEPT
- Static ID: R_TAB_DEPT
- Template Option: Hidden
π¨βπΌ Employee Tab
- Region Name: R_TAB_EMP
- Static ID: R_TAB_EMP
- Template Option: Hidden
πΉ Step 4: Create Forms Inside Tabs
Department Form
- Region Name: R_DEPT
- Based on: DEPT table
- Static ID: R_DEPT
Employee Form
- Region Name: R_EMP
- Based on: EMP table
- Static ID: R_EMP
πΉ Step 5: Add Dynamic Action (Department Tab)
Create a Dynamic Action:
- Event: On Click
- Selection Type: Region β R_DEPT
- True Action: Execute JavaScript Code
$s('PXX_TAB_ACTIVE', 'R_TAB_DEPT');
var $tabToDisable = $('.t-Tabs-item').eq(1);
// Disable visually and functionally
$tabToDisable.css({
'pointer-events': 'none',
'opacity': '0.5'
});πΉ Step 6: Add Dynamic Action (Employee Tab)
- Event: On Click
- Selection Type: Region β R_EMP
$s('PXX_TAB_ACTIVE', 'R_TAB_EMP');
var $tabToDisable = $('.t-Tabs-item').eq(0);
// Disable visually and functionally
$tabToDisable.css({
'pointer-events': 'none',
'opacity': '0.5'
});π‘ How It Works
- PXX_TAB_ACTIVE stores the current active tab
- .t-Tabs-item selects all tab elements
- .eq(N) targets a specific tab (index starts from 0)
- CSS:
- pointer-events: none β disables click
- opacity: 0.5 β visually indicates disabled state
π Handling Multiple Tabs
If you have more than 2 tabs:
$('.t-Tabs-item').eq(N);π Replace N with tab index:
- 0 β First tab
- 1 β Second tab
- 2 β Third tab
You can also loop through tabs and disable all except active one.
πΉ Step 7: Add Reset Button
Create a RESET button:
- Action: Redirect to same page
- Clear Cache: Yes
π This restores:
- All tabs enabled
- Page state reset
π― Output Behavior
β Scenario 1: Department Tab Active
- User starts typing in DNAME
- Employee tab becomes disabled
β Scenario 2: Employee Tab Active
- User starts typing in ENAME
- Department tab becomes disabled
π Benefits of This Approach
β Prevents accidental tab switching
β Improves data integrity
β Enhances user experience
β Easy to implement (no backend changes required)
β οΈ Important Notes
- This is client-side control (JavaScript)
- For critical validations, always enforce rules on the server side (PL/SQL)
- Ensure accessibility considerations if required
π Conclusion
Disabling inactive tabs based on user interaction is a powerful UX enhancement in Oracle APEX applications.
With a combination of:
- Dynamic Actions
- JavaScript
- Smart UI handling
you can easily implement this functionality without complex logic.
Love coding? Me too! Letβs keep in touch β subscribe to my website for regular chats on Oracle APEX, PL/SQL,SQL JavaScript, and CSS.




