1
votes

I have the following select statement but unsure how to setup the dynamic action to assign the current sysdate when the user select an option from with the LOV. I basically want to populate automatically the "DATE_CALLED" field to sysdate when a LOV selection is made via a Dynamic Action.

Trying to use the same processing from this thread that was against a checkbox but cannot seem to work out - see:

Oracle ApEx Checkbox to Manipulate Other Values When Checked/Unchecked

select  APEX_ITEM.HIDDEN(1,change_id) ||
        APEX_ITEM.HIDDEN(2,contact_id) ||
        APEX_ITEM.SELECT_LIST_FROM_LOV(p_idx => 10,
                                       p_value => reason_id,
                                       p_lov => 'LOV_REASONS',
                                       p_attributes => 'class="lov_select"',
                                       p_show_null => 'YES',
                                       p_null_value => NULL,
                                       p_null_text => '--- Please select a reason ---') reas,
        APEX_ITEM.TEXT(p_idx => 20, 
                       p_value => TO_CHAR(date_contacted,'DD/MM/YYYY HH24:MI'),
                       p_size => 14,
                       p_attributes => 'class="date_val" readonly="readonly" style="background-color:#B0C4DE;border:1px solid #999999;"') "DATE_CALLED",
        APEX_ITEM.TEXTAREA(p_idx => 30,
                       p_value => comments,
                       p_rows => 2, 
                       p_cols => 30 ) "MPA_COMMENT"
from  MY_TABLE

For the Dymanic Action, I have the following:

Dynamic action: "lov selection"
Event: Change
Selection Type: jQuery Selector
jQuery Selector: .lov_select (this is the class I added to the select list from lov in the sql)
Condition: JavaScript Expression
Value: ****** Unsure what I need to put here ******

For True Action, I have the following:

True Action:
Sequence: 10
Action: Execute PL/SQl Code
Fire On Page Load: No
Code: :P1_DEF_DATE := TO_CHAR(SYSDATE,'DD/MM/YYYY HH24:MI'); and have Page Item Submitted and Returned

Sequence: 20
Action: Execute JavaScript Code
Fire On Page Load: No
Code: $(this.triggeringElement).closest("tr").find("td[headers='DATE_CALLED'] input").val($v('P1_DEF_DATE'));

This code is not working as $(this.triggeringElement) is not correct for a select list.

How can I achieve what I need based on a select_list_from_lov scenario and not a checkbox?

1
It works when i try to set this up. Is there any error you're getting, or is some output not happening?Tom
Tom, I am trying to get this working for a select list selection/change but no output is appearing in date field. What should the JavaScript expression value be - see above for this Dynamic Action definition. I can't seem to get this working and I really need to work this help, so would appreciate your help. .prop('checked') is used for checkboxes - what is it for a select list?tonyf

1 Answers

1
votes

I used the condition on the checkbox to distinguish between the checked/unchecked state, and to be able to define both true and false actions. You don't really need this on the checkbox: change will fire whenever the value changes (ie: user selects another option).

However, if you want to catch an invalid/null option you could use the condition, but instead of javascript expression use one of the operators to test the value (eg: "=" with "1")

To further elaborate on the action on your select list:
this is the query i used to set up an example:

select 
apex_item.checkbox2(p_idx => 1, p_value => empno, p_attributes => 'class="check_select"') empselection,
apex_item.text(2, :P14_DEF_TEXT) empname,
APEX_ITEM.SELECT_LIST_FROM_LOV(p_idx => 3,
                                       p_value => NULL,
                                       p_lov => 'LOV_REASONS',
                                       p_attributes => 'class="lov_select"',
                                       p_show_null => 'YES',
                                       p_null_value => NULL,
                                       p_null_text => '--- Please select a reason ---') reas,
apex_item.text(4, null) some_text,
empno,
ename,
comm
from emp

I used an lov with static values for LOV_REASONS.

Dynamic action on lov select

Code in True action:

$(this.triggeringElement).closest("tr").find("td[headers='SOME_TEXT'] input").val("THIS IS A TEST");

This seems to work fine for me.