Checkbox Item check / uncheck all

If you have an ordinary checkbox item based on a list of values, here is a function which will set all the values to checked or unchecked:

function checkboxSetAll (item,checked) {
 $("#"+item+" input[type=checkbox]").attr('checked',checked);
 $("#"+item).trigger("change");
}

For example:

checkboxSetAll("P1_ITEM", true); //select all
checkboxSetAll("P1_ITEM", false); //select none

It works this way because a checkbox item based on a LOV is generated as a set of checkbox input items within a fieldset.

Note: If it’s a checkbox column in a report, you can use this trick instead: Select All / Unselect All Checkbox in Interactive Report Header

Unique constraint WWV_FLOW_WORKSHEET_RPTS_UK violated
Monitoring AWS Costs

Comments

  1. Hi Jeffrey,
    I was very happy when I ran into this article, since it was exactly what I was looking for.
    I have added the function on the page in “Function and Global Variable Declaration”.
    Then I have created 2 buttons:
    – 1 to “Select All”
    – and 1 for “Select None”
    Both buttons call the appropriate functionusing a DA.
    When I click “Select All”, the checkboxes are all selected.
    Then when I click “Select None” all boxes are unchecked.
    However when I click “Select All” again, nothing happens.
    Do you have an idea why this is and, even better, how I should resolve this?

Leave a Reply

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