APEX Checkbox to toggle show and hide a region

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search

Instruction

1. Add static ID, e.g., "REGION1" in the Attributes section of the region to control.

2. In the checkbox, add the function name to be called in the HTML Form Element Attributes of the Checkbox element.

onClick="f_ToggleRegion();"

3. Add the Javascript function in the page header.

function f_ToggleRegion() {
 
 chkbox_name = html_GetElement('P17_CHECKBOX_0').name;
 chkbox_array = document.getElementsByName(chkbox_name);

 for (i=0; i < chkbox_array.length; i++) {
   if (chkbox_array[i].checked) {
     document.getElementById('REGION1').style.display = "";
   } else {
     document.getElementById('REGION1').style.display = "none";
   }
 }
}

Sample at http://apex.oracle.com/pls/apex/f?p=57043:CHECKBOX_TOGGLE_REGION

Additional information on the use of Javascript with APEX Checkbox - http://dgielis.blogspot.com/2008/02/checkbox-in-apex.html