We help IT Professionals succeed at work.

APEX checkbox not working as expected

Rads R
Rads R asked
on
98 Views
Last Modified: 2019-03-11
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
Comment
Watch Question

Oracle dba
CERTIFIED EXPERT
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Very helpful.

Author

Commented:
Used drop down
Dmitry KurashkinDeveloper
CERTIFIED EXPERT

Commented:
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.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.