Skip to main content
sd0123
Known Participant
June 26, 2018
Answered

Help with Javascript function to show a hidden button with setTimeout

  • June 26, 2018
  • 3 replies
  • 1297 views

I have an interactive PDF with a form field button called “Nav_Forward_Page_14” that is set to hidden. I want the button to be visible 5 seconds after the page containing the button loads; so on Page Properties (for the page with the button), I've tried adding the following Javascript on page load, with no success:

setTimeout(function() {

this.getElementById("Nav_Forward_Page_14").style.display = "inline";

}, 5000);

Thinking that I may have the function wrong, I also tried:

setTimeout(function() {

this.getElementById("Nav_Forward_Page_14").display = display.visible;

}, 5000);

After more research, I've also tried:

function runImage() {

this.getField("Nav_Forward_Page_14").display = display.visible

}

run = app.setTimeout("runImage()", 5000);

Please help me correct the function necessary to show the hidden button after a delay on page load in a PDF. Thank you in advance!

This topic has been closed for replies.
Correct answer try67

The latter code will work, if you change it from setTimeout to setTimeOut ...

3 replies

try67
Community Expert
Community Expert
July 3, 2018

Don't use the same variable ("run") for each command. Name them run1, run2, run3, etc.

sd0123
sd0123Author
Known Participant
July 3, 2018

Many thanks again!

sd0123
sd0123Author
Known Participant
June 26, 2018

Yay!  Thank you

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 26, 2018

The latter code will work, if you change it from setTimeout to setTimeOut ...

sd0123
sd0123Author
Known Participant
July 3, 2018

I have a follow up question, please.  Why, and what can I do (if anything) about...

Sometimes when I go to the page with a series of buttons on setTimeOut, all of the buttons appear as scripted; but sometimes, some buttons don't appear at all - like the first, second and fifth buttons only will appear.  When I leave the page and return to it, maybe all of the buttons will appear, none or some .  Thoughts?  I can provide the code if you'd like - it does work, but not with consistency.

Thanks!

try67
Community Expert
Community Expert
July 3, 2018

Yes, please provide the code.