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
Parameter | Description |
---|---|
p_idx |
Number that determines which APEX_APPLICATION global variable is used. Valid range of values is 1 to 50. For example 1 creates F01 and 2 creates F02 |
p_value |
Value of a check box, hidden field, or input form item |
p_attributes |
Controls the size of the text field |
p_checked_values |
Values to be checked by default |
p_checked_values_delimiter |
Delimits the values in the previous parameter, p_checked_values |
p_item_id |
HTML attribute ID for the <input> tag
|
p_item_label |
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)