35.18 SWITCH Function
This function dynamically generates flip toggle item. If On/Off value and label are not passed, it renders Yes/No toggle. This function is designed to generate forms with F01 to F50 form array elements.
Syntax
APEX_ITEM.SWITCH (
    p_idx           IN NUMBER,
    p_value         IN VARCHAR2,
    p_on_value      IN VARCHAR2 DEFAULT 'Y',
    p_on_label      IN VARCHAR2 DEFAULT 'Yes',
    p_off_value     IN VARCHAR2 DEFAULT 'N',
    p_off_label     IN VARCHAR2 DEFAULT 'No',
    p_item_id       IN VARCHAR2 DEFAULT NULL,
    p_item_label    IN VARCHAR2,
    p_attributes    IN VARCHAR2 DEFAULT NULL )
    RETURN VARCHAR2;Parameters
| Parameter | Description | 
|---|---|
p_idx | 
                              Form element name. For example, 1 equals F01 and 2 equals F02. Typically the P_IDX parameter is constant for a given column.
                               | 
                           
p_value | 
                              Form element current value. | 
p_on_value | 
                              The value of the item if the user picks On option. | 
p_on_label | 
                              The display text for the On option. | 
p_off_value | 
                              The value of the item if the user picks Off option. | 
p_off_label | 
                              The display text for the Off option. | 
p_item_id | 
                              HTML attribute ID for the <input> tag. Try concatenating some string with rownum to make it unique. | 
p_item_label | 
                              Invisible label created for the item. | 
p_attributes | 
                              Additional HTML attributes to use for the form item. | 
Example
The following example demonstrates the use of APEX_ITEM.SWITCH to generate a Yes/No flip toggle item where:
                  
- A form array element F01 will be generated (
p_idxparameter). - The initial value for each element will be equal to N 
(p_valueparameter). - A HTML ID attribute will be generated for each row with the current rownum to uniquely identify. (
p_item_idparameter). An ID of'IS_MANAGER_2'is generated for row 2). - A HTML label element will be generated for each row (
p_item_labelparameter). 
SELECT
  ename "Name",
  APEX_ITEM.SWITCH ( 
       p_idx => 1,
       p_value => 'N',
   p_item_id => 'IS_MANAGER_'||rownum,
       p_item_label => apex_escape.html(ename)||': Is Manager' )
"Is Manager"
FROM emp;Parent topic: APEX_ITEM (Legacy)