How to create a timer item in Oracle Apex

By
Salin Rosna
October 29, 2020

In this blog, I’ll walk you through how to create a timer item in your Oracle Apex application.

In this example, I am creating a timer clock that starts from 00:00 that counts till the page is active. You can make modifications to your timer item to match your scenario.

Here is how I created it:

  • Create a display only item
  • Create a dynamic action which is triggered on page load.
  • Create a True action that execute JavaScript code and paste the following code in it.
  • Note: ‘P5_TIMER’ is the name of your display only item.

var timeoutHandle;
function countdown(minutes) {
var seconds = 0;
var mins = minutes
function tick() {
var current_minutes = mins
seconds++;
var c = current_minutes.toString() + ":"
+ (seconds < 10 ? "0" : "")
+ String(seconds);
apex.item('P5_TIMER').setValue(c);
if( seconds < 60 ) {
timeoutHandle=setTimeout(tick, 1000);
} else {
setTimeout(function () { countdown(mins + 1); }, 1000);
}
}
tick();
}
countdown(0);

The Timer item will look like the below image on the UI.

This image has an empty alt attribute; its file name is image-edited.png

Thanks

Salin

Salin is our Junior Dev who spends a bunch of time using Oracle Apex, when she’s not doing that she can be found busily working on our customers data.

Connect with Salin on LinkedIn or read some of her other blogs here.

Copyright © 2019 OptimalBI LTD.