Skip to main content
sd0123
Known Participant
Jun 26, 2018 5:59 PM UTC
Answered

Help with Javascript function to show a hidden button with setTimeout

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Jun 26, 2018 6:15 PM UTC

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

7 replies

try67
Community Expert
Community Expert
Jul 3, 2018 7:11 PM UTC

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

Translate
sd0123
sd0123Author
Known Participant
Jul 3, 2018 7:16 PM UTC

Many thanks again!

Translate
sd0123
sd0123Author
Known Participant
Jun 26, 2018 6:20 PM UTC

Yay!  Thank you

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Jun 26, 2018 6:15 PM UTC

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

Translate
sd0123
sd0123Author
Known Participant
Jul 3, 2018 6:33 PM UTC

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!

Translate
try67
Community Expert
Community Expert
Jul 3, 2018 7:05 PM UTC

Yes, please provide the code.

Translate