Brian Brock
Brian Brock

Reputation: 351

Hide subregion until button click

APEX 20.1 @ apex.oracle.com

I have a rather lengthy form that I need to divide into three sections so as to not overwhelm the end-user. I would like to submit the entire form to the database with a single submit event.

Therefore, I have a form region with 3 subregions inside. Each subregion contains 1/3rd of the questions. I would like to have subregion 2 and 3 hidden when the page first loads. A Continue button at the bottom of subregion 1 should HIDE subregion 1 and SHOW subregion 2.

I've created the dynamic action that will hide subregion 1, but I'm having trouble figuring out how to have the second and third subregions already hidden when the page loads.

I tried adding a page item called "currentbank" setting it's initial value to 1, and then for subregion 2, I set it's server-side to Item = Value... currentbank = 2. In the dynamic action, I then added two steps after hiding subregion 1. The first was to set value of currentbank = 2, and then to show subregion 2. This does not work however. No error message, but the subregion 2 does not become visible when I click the continue button, executing the dynamic action.

What other method could I try to initially have hidden subregions 2 and 3, and then hide the "current" region and show the next region as the user progresses through the questions?

Upvotes: 0

Views: 642

Answers (1)

Koen Lostrie
Koen Lostrie

Reputation: 18630

Server side conditions are evaluated before the page is rendered. So if the server side condition is false for a component, that will not be on the page. Dynamic Actions on the other hand, work on components that are rendered on the page.

So, if you have a component that is hidden because of a server side condition, it can never be shown by a dynamic action, simply because it is not there in the page. Your question can be solved entirely with dynamic actions. Take the example of 2 regions and 2 buttons. One button "Show Region 1" and another "Show Region 2". The desired functionality is that only that region is shown so clicking "Show Region 2" will hide region 1. The example can easily be implemented for more that 2 regions.

  • Create 3 regions ( Buttonregion, Region1 and Region2) and 2 buttons (Button1 and Button2 in region Buttonregion).
  • Add a dynamic action (Event: click Button1) on Button1 called "Show Region1". Add 2 Actions: an action to show Region1 and an action to hide Region2. Make sure the flag "fire on initialization is set to on for both actions.
  • Add a dynamic action (Event: click Button2) on Button2 called "Show Region2". Add 2 Actions: an action to show Region2 and an action to hide Region1. Make sure the flag "fire on initialization is set to off for both actions.
  • That is all there is to it. Save and test.

Upvotes: 1

Related Questions