0
votes

I am currently having an interactive report in ORACLE APEX, where i use the report to display many records as rows and columns from the database. One such column is the check box.All the check boxes in the report are rendered like this : APEX_ITEM.CHECKBOX2(1,GROUP1.CAM_QER_LINE_GROUP_ID,'UNCHECKED',p_item_id=>'p01_1')

There are buttons in the report such as 'Save' which save the changes made to the records in the report.

On clicking the Save button, all the changes made to the checked records should be going through successfully, else an alert/message or similar kind should pop-up and ask the user to check the box and save the changes.

I know there are multiple ways to do this. The ways that i have tried so far but wasn't completely successful are mentioned below.

if apex_application.g_f01.count = 0
     then   
        apex_error.add_error (
        p_message          => 'Invalid Customer ID!',
        p_display_location =>  apex_error.c_inline_with_field_and_notif,
        p_page_item_name   => 'P5_CUSTOMER_ID');
     else 
        --- DO THE REST

In this above method, I am using this code in the PL/SQL process which runs at the point of processing after clicking of the Save Button but the problem that I am facing is once the error_message is displayed, it gets re-displayed on click of even other buttons which do a submit of the page/other processing, which defeats the purpose.

    if (document.getElementById('p01_1').checked) 
        { alert("checked"); } 
   else
        { alert("Please Check the Box."); }

In this above method, the problem is that getElementById('p01_1') is not able to identify each checkbox in the report and is throwing the alert 'Please Check the Box' even if some out of all check boxes are checked.

Looking for a simple solution to this problem that I am facing.

1
How are your checkboxes looking alike in the generated HTML?Lajos Arpad
@LajosArpad I didn't quite get your questionArpan Roy
You have a web page where your checkboxes appear. You can look at the source-code of the page (generated HTML) by right-clicking on the page somewhere and clicking on view source or view page source (depending on the browser you use) in the popup menu. There you will find the generated HTML and I am interested to know the part of the HTML where your checkboxes are. If you can put that code into your question, then we may be able to help you.Lajos Arpad
@LajosArpad The code generated from inspecting the checkbox element is given below : <td class=" u-tL" headers="C616135092723269676"><div align="center" style="width:56px !important;"><input type="checkbox" name="f01" value="43219611" UNCHECKED /></div></td>Arpan Roy

1 Answers

0
votes

To iterate of every checkbox generated by apex_item.

//fXX = XX the first parameter of apex_item
var elements = document.getElementsByName('f01');

for(var i = 0; i < elements.length; i++) { 
    if(!elements[i].checked) {
        alert(elements[i] + ' not checked'); 
    }
}

1 - If all the checkbox should by checked, why do you use then?

2 - Why did you not use interactive gride?