JavaScript to run on open
Copy link to clipboard
Copied
- viewer selects a radio button option 1,2, or 3
- the corresponding layer becomes visible, along with all form functions like text boxes, check boxes, etc. that correspond with the selected layer.
- viewer fills in the form and saves it
- reviewer opens the form and instead of seeing how the form was last saved, it reverts back to the original view of the form (which is option 1). The reviewer then has to reselect (let's say option 2) on the radio button to view it correctly.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I think that you can achieve the form behavior you want. But it's not simple.
Code on form fields is driven by events, such as clicks and data changes. The Acrobat JavaScript model does not provide functions for trigging these events artificially, except for the Calculate event. The best way to share script functionality is to put that functionality into a function defined in a document level script. Then call the function whereever it is needed.
All the code in a Document level script is run when the PDF is opened. So you can use it to define shared data and functions, and to run document initialization code.
Here's an article on the topic:
https://www.pdfscripting.com/public/Document-Level-Scripts.cfm
Use the Acrobat JavaScript Reference early and often

