35.1 CHECKBOX2 Function
This function creates check boxes.
Syntax
APEX_ITEM.CHECKBOX2(
p_idx IN NUMBER,
p_value IN VARCHAR2 DEFAULT NULL,
p_attributes IN VARCHAR2 DEFAULT NULL,
p_checked_values IN VARCHAR2 DEFAULT NULL,
p_checked_values_delimiter IN VARCHAR2 DEFAULT ':',
p_item_id IN VARCHAR2 DEFAULT NULL,
p_item_label IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2;
Parameters
Table 35-1 CHECKBOX2 Parameters
Parameter | Description |
---|---|
|
Number that determines which |
|
Value of a check box, hidden field, or input form item |
|
Controls the size of the text field |
|
Values to be checked by default |
|
Delimits the values in the previous parameter, |
|
HTML attribute ID for the |
|
Invisible label created for the item |
Examples of Default Check Box Behavior
The following example demonstrates how to create a selected check box for each employee in the emp
table.
SELECT APEX_ITEM.CHECKBOX2(1,empno,'CHECKED') "Select",
ename, job
FROM emp
ORDER BY 1
The following example demonstrates how to have all check boxes for employees display without being selected.
SELECT APEX_ITEM.CHECKBOX2(1,empno) "Select",
ename, job
FROM emp
ORDER BY 1
The following example demonstrates how to select the check boxes for employees who work in department 10.
SELECT APEX_ITEM.CHECKBOX2(1,empno,DECODE(deptno,10,'CHECKED',NULL)) "Select",
ename, job
FROM emp
ORDER BY 1
The next example demonstrates how to select the check boxes for employees who work in department 10 or department 20.
SELECT APEX_ITEM.CHECKBOX2(1,deptno,NULL,'10:20',':') "Select",
ename, job
FROM emp
ORDER BY 1
Creating an On-Submit Process
If you are using check boxes in your application, you might need to create an On Submit process to perform a specific type of action on the selected rows. For example, you could have a Delete button that uses the following logic:
SELECT APEX_ITEM.CHECKBOX2(1,empno) "Select",
ename, job
FROM emp
ORDER by 1
Consider the following sample on-submit process:
FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP
DELETE FROM emp WHERE empno = to_number(APEX_APPLICATION.G_F01(i));
END LOOP;
The following example demonstrates how to create unselected checkboxes for each employee in the emp table, with a unique ID. This is useful for referencing records from within JavaScript code:
SELECT APEX_ITEM.CHECKBOX2(1,empno,NULL,NULL,NULL,'f01_#ROWNUM#') "Select",
ename, job
FROM emp
ORDER BY 1
Parent topic: APEX_ITEM (Legacy)