8 Replies Latest reply on Dec 7, 2018 4:02 PM by Noman Hameed

    multiple checkbox values

    Noman Hameed

      Hello everyone,

      i'm new to oracle apex. i'm stuck on a little point in dealing with checkbox in classical report to update status to Y or N in PLSPL using for loop please guide me. code is as below

       

       

      Select
      ID,
      STATUS,
      '<input type="checkbox" name="F01" class="confirmcheckbox" onclick="apex.item(''P14_ID'').setValue('''||ID||''');
      apex.item(''P14_STATUS'').setValue(''||STATUS||'');" value="Confirm" id="shoukatCheckbox">'  as "CHECKBOX",
      NAME
      from ALLUSERS where Status= 'N' order by 1;
      

       

      getting data to show in report

       

       

      FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP
         UPDATE ALLUSERS Set STATUS='Y' where ID=:P14_ID;
      END LOOP;
      

       

      update data on click of sava button

       

      ISSUE.png

       

       

      i want to select multiple checkbox and hit Save button to run a dynamic action to update status to "Y" of all row with selected checkbox.

       

      Oracle Apex 18.2

       

      Regards,

      Noman Hameed

        • 1. Re: multiple checkbox values
          Franck N

          Hi,

           

          Basically you want something like this : https://apex.oracle.com/pls/apex/f?p=56890:7:101037609285275:::::

           

          if yes let me know i will describe the steps to achieve this.

           

          regards,

          Franck

          • 2. Re: multiple checkbox values
            Noman Hameed

            yes sir exactly i want same thing to do

            • 3. Re: multiple checkbox values
              fac586

              4b1c22e4-698d-4982-8824-ef52e3d62ba7 wrote:

              Please update your forum profile with a recognisable username instead of "4b1c22e4-698d-4982-8824-ef52e3d62ba7".

               

              Always include the information described in these guidelines when asking a question: how to get answers from forum

              hi i'm new to oracle apex. i'm stuck on a little point in dealing with checkbox in classical report to update status to Y or N in plsql using for loop please guide me. code is as below

               

              Select

              ID,

              STATUS,

              '<input type="checkbox" name="F01" class="confirmcheckbox" onclick="apex.item(''P14_ID'').setValue('''||ID||''');

              apex.item(''P14_STATUS'').setValue(''||STATUS||'');" value="Confirm" id="shoukatCheckbox">' as "CHECKBOX",

              NAME

              from ALLUSERS where Status= 'N' order by 1;

              Always post code using the syntax highlighting feature in the advanced editor.

              getting data to show in report

               

               

              FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP

              UPDATE ALLUSERS Set STATUS='Y' where ID=:P14_ID;

              END LOOP;

               

              update data on click of sava button

               

              ISSUE.png

              That looks like an interactive rather than a classic report?

              i wana select multiple checkbox and hit Save button to run a dynamic action to update status to Y of all row with selected checkbox.

              OTN is not SMS, Twitter, or Facebook. This is a professional community and professional standards of discourse are expected. Posts should use language appropriate to a commercial email, not casual texting between 12 year olds.

               

              This article describes a comprehensive solution to this problem. To process the selection using an Execute PL/SQL dynamic action rather than on page submission, include the selection item (P1_SELECTED in the example) in the DA Items to Submit property, and convert it to a collection using the appropriate apex_string.split* API method:

               

              declare
              
                selected_users apex_t_number;
              
              begin
              
                selected_users := apex_string.split_numbers(:p14_selected, '|');
              
                for i in 1..selected_users.count
                loop
                  update
                      allusers
                  set
                      status= 'y'
                  where
                      id = selected_users(i);
                end loop;
              
              end;
              

               

              Better still, if the join result is key preserved, do it directly in DML:

               

              begin
              
                update
                    (select
                        au.id
                      , au.status
                    from
                        allusers au
                          join table(apex_string.split_numbers(:p14_selected, '|')) su
                            on au.id = su.column_value)
                set
                    status= 'y';
              
              end;
              

               

              Include a second true action on the DA to Refresh the report region.

               

              Make sure that you understand the APEX architecture and basic processing model. Performing DML in dynamic actions is the exception rather than the rule. Processing data using page processes during page submit processing is by far the simplest and most effective approach available.

              • 4. Re: multiple checkbox values
                fac586

                4b1c22e4-698d-4982-8824-ef52e3d62ba7 wrote:

                 

                yes sir exactly i want same thing to do

                Do not mark posts as correct until the problem is completely resolved.

                • 5. Re: multiple checkbox values
                  Franck N

                  ok,

                  the same goes for an Interactive report.

                  then let' s do this.

                   

                  Step1:

                  adjust your query like Bellow:

                  Select
                  ID,
                  STATUS,
                  APEX_ITEM.CHECKBOX2(p_idx => 1, 
                                      p_value => ID,
                                      p_attributes => 'class="boxes"') AS SELECTOR,
                  NAME
                  from ALLUSERS where Status= 'N' order by 1;
                  

                   

                  This Item of yours wont be required anymore you can delete it P14_ID.

                  step 2 : for select all and deselect all: add this code on the Heading of you column like on the picture bellow:

                  <input type="Checkbox" onclick="$f_CheckFirstColumn(this)">
                  

                   

                  Sortable NO  ,escape  special character No also.

                   

                  Step 3:

                  create a process of Type AJAX- Callback with the name "SET_Y" with the Following code (in my case i have 2 Process for Y and for N) if you need Both then just create another Process same code but the value will change Accordingly with yes or no:

                  BEGIN
                   FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP
                  --case for Y
                     UPDATE ALLUSERS  Set STATUS='Y' where id= APEX_APPLICATION.G_F01(I);
                     END LOOP;
                     --this is the message to be displayed in the alert
                     htp.p('{ "message": "' || APEX_APPLICATION.G_F01.COUNT || ' rows updated" }');
                  
                  
                  END;
                  

                   

                  Step 4 : create a Button 'save' and a  Dynamic action on click on the Button with 2 true action

                            - First True Action execute this Javascript code:

                  var f01_array = [];
                  
                  
                  /* Push the values of each checkbox in the above array */
                  $('.boxes:checked').each(function() {
                   f01_array.push($(this).val());
                  });
                  
                  
                  /* Run the AJAX process to Set values in the rows and pass the F01 array */ 
                  //SET_Y is the name of your AJAX CALLBACK Process
                  apex.server.process( "SET_Y", 
                   { f01 : f01_array },
                   { success : function(data){ 
                   //this code will work and display a success message if you have APEX 5.1 or greater since you didn't give any infos about your apex version 
                    apex.message.showPageSuccess(data.message); 
                   }
                   }
                   );
                  

                            - Second True action of type refresh on your classic/ interactive report region

                   

                   

                  step5 : Test

                   

                  additional settings in case of an IR:

                   

                  regards,

                  Franck

                  • 6. Re: multiple checkbox values
                    Pierre Yotti

                    fac586 wrote:

                     

                    4b1c22e4-698d-4982-8824-ef52e3d62ba7 wrote:

                     

                    yes sir exactly i want same thing to do

                    Do not mark posts as correct until the problem is completely resolved.

                     

                    where is this defined that the OP must mark the posts as correct only when the problem is completely solved.

                    • 7. Re: multiple checkbox values
                      fac586

                      Alli Pierre Yotti wrote:

                       

                      fac596 wrote:

                       

                      4b1c22e4-698d-4982-8824-ef52e3d62ba7 wrote:

                       

                      yes sir exactly i want same thing to do

                      Do not mark posts as correct until the problem is completely resolved.

                       

                      where is this defined that the OP must mark the posts as correct only when the problem is completely solved.

                      How can a response be considered to be "correct" if it does not clearly explain how to resolve the stated problem?

                       

                      The post concerned provides no information to the OP or other users about the actual nature of the solution.

                       

                      The purpose of marking a post as "correct" is twofold:

                       

                      1. It shows that the poster of the question considers the contents of that post to resolve the stated issue. This effectively closes the thread as it indicates that they no longer consider there to be a problem. (This does not preclude further activity on the thread: the OP may not fully understand the implications of the problem or their chosen "solution", or a better solution may be subsequently posted.)
                      2. It indicates content that may be considered to provide a complete solution to other users with the same or similar problems.

                       

                      Marking posts that do not meet these criteria as correct does not benefit the community: HTML Form Element CSS Class Values - Where From?

                      • 8. Re: multiple checkbox values
                        Noman Hameed

                        Sorry i already mention that i'm totally new in apex & this is my first post so i have no idea about rules & way to format post but thanks to you i update formatting of post using your guideline.