APEX checkbox not working as expected

Hi APEX masters,

I have a checkbox with 2 values (val1, val2) ,
1. If I don't check any , it would execute one function1
2. If I click on val1 the  function2 executes
3. If I click on val2 , the  function3 executes and all 1,2,3  steps works fine

But when I click both (val1 and val2) it should execute another function4 but it is executing function1

I am selecting the checkbox values from a table with display and return values.
And in the code I am checking with the return values of the checkbox.

What am I doing wrong here, can anyone please let me know.

Thanks,
R
Rads RAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
it would be easier to use a dropdown to select what function needs executing
or use a button for each function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rads RAuthor Commented:
Very helpful.
Rads RAuthor Commented:
Used drop down
Dmitry KurashkinDeveloperCommented:
Hello Rads,

I would agree with Geert that it is easier sometimes to use a select list with 4 options if you need to run 4 functions. But if the logic of the application requires to use 2 checkboxes, you can do the following:
1. If the processing is in PL/SQL, the value of the standard APEX checkbox consist of return values delimited with ":". So, if you have return values "val1" and "val2", and user had checked both, you will have value "val1:val2". To process it:
if :P1_CHECKBOX = '' then
    procedure1(...);
elsif :P1_CHECKBOX = 'val1' then
    procedure2(...);
elsif :P1_CHECKBOX = 'val1' then
    procedure3(...);
elsif :P1_CHECKBOX = 'val1:val2' then
    procedure4(...);
end if;

Open in new window

But in the case when you have more then 2 checkboxes situation becomes more complicated. It is better to check the presence of value with instr function:

if :P1_CHECKBOX = '' then
    procedure1(...);
elsif instr(:P1_CHECKBOX, 'val1') > 0 and instr(:P1_CHECKBOX, 'val2') = 0 then
    procedure2(...);
elsif instr(:P1_CHECKBOX, 'val2') > 0 and instr(:P1_CHECKBOX, 'val1') = 0 then
    procedure3(...);
elsif instr(:P1_CHECKBOX, 'val1') > 0 and instr(:P1_CHECKBOX, 'val2') > 0 then
    procedure4(...);
end if;

Open in new window


2. The same thing is in Javascript, if you want to process on the client side, but in this case, the delimiter is the comma.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.