Skip to main content
November 10, 2016
Question

I have a pdf page with 6 buttons. How do I change the action using javascript?

  • November 10, 2016
  • 3 replies
  • 586 views

I have a page with 6 buttons.  How do I change the action using javascript?

This topic has been closed for replies.

3 replies

November 10, 2016

I am looking to open a bookmark with the code below instead of going to a page number.

var f = this.getField("Button1");  f.setAction("MouseUp", "this.pageNum = 1";

try67
Community Expert
Community Expert
November 10, 2016

You'll need to iterate over the entire bookmark tree, looking for that bookmark's name, and when you find it you can use the execute method to run the action associated with it.

November 10, 2016

Thanks.  Can you also tell me how to set the action to open a bookmark?

try67
Community Expert
Community Expert
November 10, 2016

What do you mean by "open a bookmark", exactly?

Joel Geraci
Community Expert
Community Expert
November 10, 2016

Something like this...

this.getField("BUTTONNAME").setAction(trigger, code);

The trigger is a string and can be any one of...

MouseUp

MouseDown

MouseEnter

MouseExit

OnFocus

OnBlur

Keystroke

Validate

Calculate

Format

code is also a string but it's the JavaScript that gets executed this this...

"app.beep(0);"