Print
06
August
2010

Select All / Deselect All

(written for Apex v 3.x)


To make it easy for you application users, there may sometimes be the need for a "Select All" and "Deselect All" functionality for your checkbox group.

In this example, I have used icon buttons for the functions, as seen in the image below.


select_deselect_all


1) I uploaded the images I want to user for my buttons into the shared components of my application. These images are called:
deselect_all.gif
select_all.gif


2) I have then created a checkbox item on my page called P1_BUSINESS_GROUP.

3) I have placed this checkbox within its own Page Region, the title of this region being "Business Group", which is what is displayed in the image.

4) Place this javascript function into the HTML Header of your page definition:

<script type="text/javascript"></span><br /><span class="Moobi_Code">function get_Checkboxes(p_itemname)
{
 var ip=document.getElementsByTagName('INPUT');
 var ret=new Array();
 var regexp=new RegExp('^'+p_itemname+'_');
 for (var j=0;j<ip.length;j++) {
   if (ip[j].type=="checkbox"
   && ip[j].id && ip[j].id.match(regexp))
      ret.push(ip[j]);
 }
 return ret;
}
</script>



4) In the LABEL field of my P1_BUSINESS_GROUP item, I have placed the following code:

<a href="#"  onClick="html_CheckAll(null,true,get_Checkboxes ('P36_BUSINESS_GROUP'))"> <img src="#WORKSPACE_IMAGES#select_all.gif"   valign="bottom"  title="Select All"></a> &nbsp; <a href="#"  onClick="html_CheckAll(null,false,get_Checkboxes ('P36_BUSINESS_GROUP'))"> <img src="#WORKSPACE_IMAGES#deselect_all.gif"  valign="bottom"  title="Unselect All"></a></span><br /><br /><br /><img src="images/stories/APEX/Items/select_deselect_all_fieldcode.jpg" alt="select_deselect_all_fieldcode" width="634" height="135" />

<script type="text/javascript"><br />function get_Checkboxes(p_itemname)<br />{<br /> var ip=document.getElementsByTagName('INPUT');<br /> var ret=new Array();<br /> var regexp=new RegExp('^'+p_itemname+'_');<br /> for (var j=0;j<ip.length;j++) {<br />   if (ip[j].type=="checkbox"
   && ip[j].id && ip[j].id.match(regexp))
      ret.push(ip[j]);
 }
 return ret;
}
</script>

Interested in building next-gen Big Data architecture? Join our webcast on 5/24 at 9am PT. Register here: http://t.co/k5Dsfskg

Oracle Oracle

#Oracle User Groups: Are You a Member Yet? Learn more about our 870 User Groups worldwide and become a member today: http://t.co/LsktPjH5

Oracle Oracle