admin管理员组

文章数量:1320588

I have a report with checkboxes in each row and one submit button. I want to disable button when all checkboxes are unchecked. Button should be only enabled when at least one checkbox is checked on report. I tried to do this by creating a dynamic action of type enable/disable. When no checkboxes is checked the button is disabled but when there is at least one check, button is still disabled. I tried also javascript to to this but I couldnt acplish because of my poor js knowledge. The codes I tried are below:

$("input[type='submit']").prop('disabled',true);
if ( $(this.triggeringElement).is(':checked') )
    $("input[type='submit']").prop('disabled',true);

///

if ($('input[type='checkbox']:checked').length > 0 && $("input[type='submit']").is(':disabled')) {
    $("input[type='submit']").removeAttr('disabled')
} else if ($('input[type='checkbox']:checked').length == 0) {
    $("input[type='submit']").attr('disabled', true)
}

Query of report:

SELECT  APEX_ITEM.CHECKBOX2(1,URUN.BARKOD, 'class=indCheck') "Select", U.AD, MA.AD MAGAZA_ADI, FIYAT, APEX_ITEM.SELECT_LIST(
        p_idx           =>   2,
        p_list_values   =>   '1;1,2;2,3;3,4;4,5;5,6;6,7;7,8;8,9;9,10;10',
        p_show_null     =>   'YES',
        p_null_value    =>   NULL,
        p_null_text     =>   '-0-',
        p_item_id       =>   'indSelect') "Adet"
FROM URUNSATIS URUN, UYE UN, ADRES AD, ANLASMALAR AN, MAGAZA MA, URUN U
WHERE UN.USERNAME = :SESSION_USER_NAME AND UN.ID = AD.UYE_ID AND AD.APARTMAN_ID = AN.APARTMAN_ID AND AN.MAGAZA_ID = URUN.MAGAZA_ID AND MA.ID = URUN.MAGAZA_ID AND U.BARKOD=URUN.BARKOD
ORDER BY 1;

I have a report with checkboxes in each row and one submit button. I want to disable button when all checkboxes are unchecked. Button should be only enabled when at least one checkbox is checked on report. I tried to do this by creating a dynamic action of type enable/disable. When no checkboxes is checked the button is disabled but when there is at least one check, button is still disabled. I tried also javascript to to this but I couldnt acplish because of my poor js knowledge. The codes I tried are below:

$("input[type='submit']").prop('disabled',true);
if ( $(this.triggeringElement).is(':checked') )
    $("input[type='submit']").prop('disabled',true);

///

if ($('input[type='checkbox']:checked').length > 0 && $("input[type='submit']").is(':disabled')) {
    $("input[type='submit']").removeAttr('disabled')
} else if ($('input[type='checkbox']:checked').length == 0) {
    $("input[type='submit']").attr('disabled', true)
}

Query of report:

SELECT  APEX_ITEM.CHECKBOX2(1,URUN.BARKOD, 'class=indCheck') "Select", U.AD, MA.AD MAGAZA_ADI, FIYAT, APEX_ITEM.SELECT_LIST(
        p_idx           =>   2,
        p_list_values   =>   '1;1,2;2,3;3,4;4,5;5,6;6,7;7,8;8,9;9,10;10',
        p_show_null     =>   'YES',
        p_null_value    =>   NULL,
        p_null_text     =>   '-0-',
        p_item_id       =>   'indSelect') "Adet"
FROM URUNSATIS URUN, UYE UN, ADRES AD, ANLASMALAR AN, MAGAZA MA, URUN U
WHERE UN.USERNAME = :SESSION_USER_NAME AND UN.ID = AD.UYE_ID AND AD.APARTMAN_ID = AN.APARTMAN_ID AND AN.MAGAZA_ID = URUN.MAGAZA_ID AND MA.ID = URUN.MAGAZA_ID AND U.BARKOD=URUN.BARKOD
ORDER BY 1;
Share Improve this question edited Aug 18, 2017 at 13:00 Thomas Tschernich 1,28215 silver badges30 bronze badges asked Aug 18, 2017 at 12:01 Arda TümayArda Tümay 971 silver badge12 bronze badges 1
  • You should provide the minimal HTML code of your report that reproduces the issue. – tima Commented Aug 18, 2017 at 12:17
Add a ment  | 

2 Answers 2

Reset to default 7

You will need a static ID for the button to better identify it using Javascript - for example BUTTON1.

Now, create a dynamic action.

Event: CHANGE

Selection Type: jQuery Selector

jQuery Selector: input.indCheck

This will trigger the dymanic action whenever one of the checkboxes is clicked. As the Action of the dynamic action, choose Execute JavaScript Code and use the following Code:

if ($(".indCheck:checked").length == 0) {
    $("#BUTTON1").addClass("apex_disabled");
} else {
    $("#BUTTON1").removeClass("apex_disabled");
}

This will count all the checked checkboxes. In case the amount is zero, it will deactivate the button. If the amount is at least one, it will activate the button. Be careful with the static ID of the button, it needs to match.

I'd prefer use APEX native JS API over jQuery method.

apex.item( "P1_ITEM" ).enable();
apex.item( "P1_ITEM" ).disable();

本文标签: javascriptDisabling or enabling a button depending on checkboxes oracle apexStack Overflow