Skip to main content
Luxurynightmares
Known Participant
June 9, 2023
Answered

Acrobat Javascript, How do you reset a timer?

  • June 9, 2023
  • 2 replies
  • 1496 views

My script is this:

 

this.getField("TextField").display = display.visible;

app.setTimeOut ('this.getField("TextField").display = display.hidden;', 9000 );

 

This works fine as it will show the text field and hide it after 9 seconds.  But if a user spams the button it does not work so well. 

 

Is there a way to reset the timer if someone spams the button?

This topic has been closed for replies.
Correct answer try67

Yes, this is possible, and is explained in the samples of the setTimeOut method.

Here's an example:

 

if (timer1!=null) app.clearTimeOut(timer1);
timer1 = app.setTimeOut('this.getField("TextField").display = display.hidden;', 9000 );

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 10, 2023

Yes, this is possible, and is explained in the samples of the setTimeOut method.

Here's an example:

 

if (timer1!=null) app.clearTimeOut(timer1);
timer1 = app.setTimeOut('this.getField("TextField").display = display.hidden;', 9000 );

Luxurynightmares
Known Participant
June 10, 2023

You're a genius!  This exactly answers my question.  Thank you so much!

Bernd Alheit
Community Expert
Community Expert
June 10, 2023

What does you mean with "spams the button" ?

Luxurynightmares
Known Participant
June 10, 2023

By "spams the button" I mean if the user rapidly and repeatedly clicks on the button. 

For instance, if a user rapidly pressed the button 10 times, my script will just keep adding 9 seconds 10 times. 

I would like the timer to reset if someone presses the button while the timer is still going.

Bernd Alheit
Community Expert
Community Expert
June 10, 2023

You can hide the button.