Search code examples
htmloracle-apex

Conditionally display/hide universal icon in inline help text in APEX


I'm working with APEX ORACLE ver 23.1. My problem is to conditionally display or hide fa-warning in inline help text of one page item (P1_item1). The condition is based on another page item:

  • display if P1_item2 <> ''
  • hide if P1_item2 = ''

And the help text will be the following

if P1_item2 <> ''
<span class="fa fa-warning" aria-hidden="true"></span> &P1_item2.

If anyone of you have an idea about how to solve this?

Thanks in advance.


Solution

  • As stated in the help attribute of the inline help text, the type should be a HTML statement: HTML

    So to have conditional values, you need to create another page item such as P1_INLINE_HELP_TEXT and then you can reference this page item as &P1_INLINE_HELP_TEXT.

    The new page item should contain the HTML text computed/calculated by a dynamic action or a process either on page load or on a change of value etc.

    The source of the page item P1_INLINE_HELP_TEXT should look like something like this:

    case when ( :P1_ITEM2 != 30  ) then '<span class="fa fa-warning" aria-hidden="true"></span>' else null end
    

    EDIT

    As you mentioned the HTML calculated displayed as text and not rendered, use a JQuery snippet like this:

    $('#P1_ITEM_inline_help').html($('#P1_ITEM_inline_help').text());
    

    This will get the text of the span (i.e " < span class="fa fa-warning" > </ span>") and set it as HTML.