in ,

Limiting To Select Only 5 Check Boxes Out Of Ten In Oracle Forms

Suppose you want to give an option to user to select only 5 check boxes from given any number of check boxes in an Oracle Form and if user selects more than 5 than give a message that you can not select more than 5.

For this follow these steps:

Create 10 check boxes in block with name like checkbox1, checkbox2, checkbox3 and so on.

Then write the When-Checkbox-Changed trigger at block level and put the following code in it:

declare
nlabel number := 1;
total_checked number := 0;
begin
while nlabel <= 10 loop
  if checkbox_checked('block3.CHECKBOX'||nlabel) then
  total_checked := total_checked + 1;
  if total_checked > 5 then
   message('more than 5 selected.');
   copy('N', :System.Cursor_Item);
   exit;
  end if;
  end if;
  nlabel := nlabel + 1;
end loop;
raise form_trigger_failure;
end;

Written by Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of foxinfotech.org and orclqa.com a question and answer forum for developers.

Leave a Reply

Your email address will not be published. Required fields are marked *