My blog is to relay my thoughts, talk about APEX and Oracle. It's also to post any adventures I have along the way.
Saturday 25 February 2012
Dynamic Action Hide and Show Example
Recently I have seen a few people posting on the forum asking how you can hide and show items in APEX 4 and above, because of this I thought I would do a quick example.
The example is based on a simple registration form where a user can either choose to complete a private registration or register with company details.
I didn’t require the company information from the user if they was registering privately so I wanted to hide these fields.
So this is what I did, the first thing was to create my page items:
Page 102 is where I created my items and is where they will appear. The item that determines if they are hidden or shown is the P102_REGISTRATION_TYPE which is a select list item and has the following static values: STATIC2:Private;PRIVATE,Company;COMPANY
The next step is to create a dynamic action that will hide and show the various items.
First we have to say when it will fire
This states that when the P102_REGISTRATION_TYPE item which is the select list is changed and has a value of COMPANY then we want to the true actions to fire if not then the false actions should fire
The true and false actions can be seen below
So in the true actions I wanted to show the company items but hide the address item as I don’t need both a company and personal address.
In the false action I needed the address but nothing else
I have also checked the box when creating them that states that I want it to fire on page load.
This is a very simple way to hide and show items in a page dynamically without the page needing to be reloaded each time the select list is changed.
Previously jQuery was used to perform such actions but with the inclusion of dynamic actions in APEX 4 this became very simple using the approach above.