Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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 );
Copy link to clipboard
Copied
What does you mean with "spams the button" ?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You can hide the button.
Copy link to clipboard
Copied
Good idea, thank you sir!
Copy link to clipboard
Copied
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 );
Copy link to clipboard
Copied
You're a genius! This exactly answers my question. Thank you so much!
Copy link to clipboard
Copied
When I closed out the PDF and reopen it, it seems to get a javascript error that timer1 is not defined. Any insight on why?
Copy link to clipboard
Copied
Add a doc-level script with this code:
var timer1;
Copy link to clipboard
Copied
Thank you

