I created an item P1_checkbox
in Oracle APEX, using LOV(select ename, empno from emp WHERE ename LIKE 's%';)
which gives multiple checkboxes.
When I check the boxes, I want to INSERT
the checked boxes data into another table "emp_selected"
.
Then, when I login into the application again, the application now should have the checkboxes ticked(checked) based on the data inserted into the table "emp_selected"
along with unchecked boxes from table "emp"
and when I uncheck some of pre-selected checkboxes and check the new checkboxes, it should be updated accordingly in "emp_selected"
.
My Oracle APEX version is 4.2.
An apex checkbox with multiple checkboxes will save its state as all selected values concatenated to eachother with a colon, eg One:Two:Three
.
So you will have to seperate those values, loop over them, and save them.
And you will need to configure your checkbox source correctly.
See the sample page I set up (apex_demo/demo)
All my setup is on that page too. For the sake of the example I'm using an apex collection to simulate a table which stores the values. The principle is the exact same - you'll simple need to adapt to your table with your selections.
Checkboxes LOV SQL:
select ename, empno from emp
Checkboxes Source settings:
Source: Always - SQL Query return colon seperated value
select c001
from apex_collections
where collection_name = 'CHECKBOX_EXAMPLE'
This will take all the values selected and concatenate them to eachother with a colon. And the checkbox will take those values and mark them as being selected.
An after submit process:
DECLARE
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
BEGIN
apex_collection.create_or_truncate_collection('CHECKBOX_EXAMPLE');
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(:P37_CHECKBOXES);
FOR z IN 1..l_vc_arr2.count LOOP
apex_debug.message(l_vc_arr2(z));
apex_collection.add_member(p_collection_name => 'CHECKBOX_EXAMPLE', p_c001 => l_vc_arr2(z));
END LOOP;
END;