Difference between revisions of "APEX Checkbox to toggle show and hide a region"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
(Created page with "Sample code at http://apex.oracle.com/pls/apex/f?p=57043:CHECKBOX_TOGGLE_REGION Category: Oracle APEX")
 
 
Line 1: Line 1:
Sample code at http://apex.oracle.com/pls/apex/f?p=57043:CHECKBOX_TOGGLE_REGION
+
<b>Instruction</b>
  
 +
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 <b>HTML Form Element Attributes</b> of the Checkbox element.
 +
 +
<pre>
 +
onClick="f_ToggleRegion();"
 +
</pre>
 +
 +
3. Add the Javascript function in the page header.
 +
<pre>
 +
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";
 +
  }
 +
}
 +
}
 +
</pre>
 +
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
 
[[Category: Oracle APEX]]
 
[[Category: Oracle APEX]]

Latest revision as of 13:13, 14 March 2012

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