APEXblog.nl - Tips and Tricks

About This Blog:
I (Richard Weug) started this blog primary for myself to save all kinds of Apex tips and tricks in one place. To use it as a place to write down how I used some coding in my own projects, but also to copy and paste all kinds of articles I find on the Internet. (So I never have to wonder on what website did I read about??? When I see something interesting I collect the content so I have my own archive/knowlegde base.

View my profile on LinkedIn

 

Tips & Tricks

Print
10
Feb

Simple Checkbox

Written by Richard Weug. Posted in Tips and Tricks

Today I was struggeling with checkboxes.

In my situation, I have 4 checkbox questions  (Yes/No)  but I only want to show 1 checkbox (checked= Y else N)
For every checkbox I had a LOV query as:  select '' d   , 'Y' r    from   dual
In a computation I would make the checkbox have the value 'N' when the value of the checkbox was still Null.
Everything works fine,.. until you want te create a dynamic action...

I try tro create a dynamic action so that when two specific checkboxes of the four in total were checked,.. it has to show an item and a button,
but I cannot get this fully to work properly.

When I check one of the checkbox,.. I get to see the button,.. that's Okay
When I uncheck the checkbox, it hides the button,.. that's Okay
When I check two checkboxes,.. it shows the button,... but then when I uncheck 1 of the 2 checkboxes,.. the button is hidden!!
The button should only be hidden when BOTH checkboxes are unchecked

I must be something simple I guess,.. has anyone got an idea about this ??
Please read on to see the dynamic actions too.....

Dynamic action 1:
Event:  Change
Selection type: item(s)
Items:    P6_DERDENG, P6EXT_FIN
Condition: no condition

Condition:
type:  PL/SQL returning Boolean
Expression:
IF (:P6_DERDENG = 'J' or :P6_EXT_FIN = 'J') then
return TRUE;
end if;

Action: Show the button (no automatic false action created)

 

Dynamic action 2:
Event:  Change
Selection type: item(s)
Items:    P6_DERDENG, P6EXT_FIN
Condition: no condition

Condition:
type:  PL/SQL returning Boolean
Expression:
IF (:P6_DERDENG != 'J'   AND  :P6_EXT_FIN != 'J' ) THEN
 RETURN TRUE;
end if;

Action: Hide the button (no automatic false action created)
Why does the button not hide when I uncheck both checkboxes?

I think the (interal) value of P6_DERDENG is still J.  That must be why the P6_DERDENG never meets the condition that it is !=  'J'
Am I right? anyone ??

 

I cannot just change this function, but when again I need to use a checkbox and only want to show 1 checkbox for Y/N,.. then I will try the simple checkbox, the Oracle plugin:

Simple Checkbox

Original article about the plugin can be found at: http://apex.oracle.com/pls/apex/f?p=654321:206:0:::::

  1. Check/Uncheck the checkboxes and have a look at the current value.
  2. Get it from our Plug-In Repository!

Note 1: The value of the page item will also be set if the checkbox is unchecked. Not like the regular checkbox which will just contain a value if checked and which returns NULL if unchecked. Defining a Simple Checkbox is also a lot easier than using the regular checkbox.

Note 2: To programmatically modify a checkbox in the browser, you can use the "Set Value" dynamic action with the "Checked Value" (for example Y) to set it or with N to uncheck it. In JavaScript you would use $s('PAGE_ITEM_NAME', 'Y') and $s('PAGE_ITEM_NAME', 'N').

Download the Simple checkbox plugin here:  Download Simple Checkbox Plugin
Another link with a solution: https://forums.oracle.com/forums/thread.jspa?threadID=2209396