Copy link to clipboard
Copied
I have a page with 6 buttons. How do I change the action using javascript?
Copy link to clipboard
Copied
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);"
Copy link to clipboard
Copied
Thanks. Can you also tell me how to set the action to open a bookmark?
Copy link to clipboard
Copied
What do you mean by "open a bookmark", exactly?
Copy link to clipboard
Copied
There are examples of finding and executing bookmarks all over this forum. Just find the one that worksfor you and put it in the JavaScript "code" string in my example above.
Copy link to clipboard
Copied
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";
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
See bookmark.execute() method in the JavaScript API Reference for an example.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now