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
2 Answers
Reset to default 7You 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
版权声明:本文标题:javascript - Disabling or enabling a button depending on checkboxes oracle apex - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742087703a2420080.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论