Expand my Community achievements bar.

SOLVED

LiveCycle Form Timer Example Needed

Avatar

Level 9

Does anyone have a LiveCycle form count up timer example they can share? The timer needs to have a start and stop buton and a reset/clear button.

I have seen an example in an Acrobat form but do not know how to create one in LiveCycle.

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 8

Assume the counting field TextField1 with a default value of 0 is in subform Main,

For the start button:

global.t = app.setInterval("xfa.form.form1.Main.TextField1.rawValue=parseInt(xfa.form.form1.Main.TextField1.rawValue)+1;",1000);

 

For the stop button:

app.clearInterval(global.t);

For the reset button:

TextField1.rawValue=0;

Kyle

View solution in original post

11 Replies

Avatar

Correct answer by
Level 8

Assume the counting field TextField1 with a default value of 0 is in subform Main,

For the start button:

global.t = app.setInterval("xfa.form.form1.Main.TextField1.rawValue=parseInt(xfa.form.form1.Main.TextField1.rawValue)+1;",1000);

 

For the stop button:

app.clearInterval(global.t);

For the reset button:

TextField1.rawValue=0;

Kyle

Avatar

Level 9

Kyle,

First of all - thanks so much for replying to my request. I really appreciate your help!

I created the timer as you directed but when testing it in the LiveCycle preview mode, the timer keeps stopping at various amounts of time (usually in less than 10 seconds) However, when opening the form outside of LiveCycle, it appears to work correctly. Any idea why it stops working in LiveCycle preview? (form is linked below).

Also: When the timer is stopped, I would like to convert the total elapsed time to HH:MM:SS - maybe in a different TextField "window" - is there a way to do this?

https://workspaces.acrobat.com/?d=ksoCJwbwUmCSJZmLe-P09g

Thanks again so very much for your help with this.

~Don

Avatar

Level 8

I'm not sure why that happens in the preview. Does it stop completely? I've had experience where the preview doesn't work and the stand alone app does and in most cases I'm just happy it works in the standalone and leave it at that.

For the time format put the following code in the calculate event (or whatever event you want) of the TextField you want to see it formatted, where TextField1 is the field showing the total amount of seconds:

 

var

a = TextField1.rawValue;

seconds = a % 60;

a /= 60;
minutes = Math.floor(a % 60);
a /= 60;
hours = Math.floor(a % 24);
this.rawValue=hours+":"+(String(minutes).length==1 ? "0":"")+minutes+":"+(String(seconds).length==1 ? "0":"")+seconds;

I'm sure there's probably a FormCalc trick or display pattern out there that mitigates the need for all that code but this works too.

Kyle

Avatar

Level 9

Kyle,

Yes, it stops completely but seems to work great outside of LiveCycle. The formatting for the display works great too! Thanks again so very much.

~Don

Avatar

Level 9

A couple timer problems I've noticed:

  1. If you hold the left mouse button down the timer stops, even if you do this on a different PDF document.
  2. If you right click and open a menu, the timer stops until the menu is closed.
  3. If you open any of the Acrobat toolbar menus, the timer stops until the menu is closed.
  4. You are unable to highlight and copy text in the document while the timer is running.

Note: Opening dropdown list objects on the form do not stop the timer.

Is there any way to fix these? I tried changing the security settings did not help.

Thanks,

~Don

Avatar

Level 8

I doubt there's any way to fix that.

Kyle

Avatar

Level 9

Okay, thanks Kyle. It works great!

-Don

Avatar

Level 3

Can you please explain more since I am receiving error while applying for this, I have been searching for months after this code to set my timer and work nicely as clock , is there video or anything that can you provide me please

Avatar

Level 9

Sorry, I no longer have that script or the form.

Avatar

Level 3

Hi dear,

can you send me your form example I really appreciate it I can use your timer for my form , please it will be a great help to me please

send to my email

love.k2008@yahoo.com

Avatar

Level 9

Sorry, like I wrote prior, I no longer have the form or the script. That was 4 years ago!