Search code examples
oracle-sqldeveloperoracle-apexoracle-apex-5oracle-apex-5.1

Double click in date field should display the current date


I have 2 items :P1_START_DATE and :P1_END_DATE.

I need to display the current date in these two field when I double click the items, I need this through dynamic action.

Thanks! Abinnaya


Solution

  • You can create a Dynamic Action that triggers on Event: Double Click, Selection Type: Item(s), and Item(s): :P1_START_DATE for each of your items.

    Then your True Action should be Execute JavaScript with the code like this:

    var myDate = new Date();
    var dd = String(myDate.getDate()).padStart(2, '0');
    var mm = String(myDate.getMonth() + 1).padStart(2, '0');
    var yyyy = myDate.getFullYear();
    
    // Here you can format your date the way you want it to look.
    myDate = mm + '/' + dd + '/' + yyyy;
    
    apex.item("P1_START_DATE").setValue(myDate);