Copy link to clipboard
Copied
Hello,
I have designed some forms in Acrobat that use layers to display different information based on the category of the person filling out the form. They select their category on page of the form and then based on their choice, the rest of the form is customized for that category.
The layers were built in Indesign and exported. The form fields are turned on and off via the "show/hide a field" action in the button definition for each layer.
The problem is that there are dozens of fields to turn off and on for each button and once I've set the action, there is no way I know of to see a list of which fields are controlled by each button. If I edit the button, I can access the actions list but I have to click on each one in the list independently to see what field is assigned to it, and the list itself is a small scrolling window and every time you close an action it resets to the top of the scrolling window.
I would love to be able to see a list of all the fields controlled by this button and what each action does, and ideally to be able to add or edit the actions performed without having to go through this interface. It's really time-consuming and impossible to figure out if I have the hide or show value set up incorrectly because it takes forever to find that particular field's setting again.
I haven't learned javascript yet, and I think I need to asap.
Meanwhile - on a hunch, I made a copy of the pdf, changed the extension to .zip, and opened it in BB Edit. So, I see lots of these command lines, which I know must be the javascript for showing and hiding the fields. The fieldnames are in parentheses in the code below.
So, I can see all of these but how can I edit these? Can I turn these into a script and change them in Acrobat?
Is there a simple script "shell" that I can paste them into and have the button run the script instead of the separate actions?
1820 0 obj
<</Next 1822 0 R/PreserveRB false/S/SetOCGState/State[/OFF 1562 0 R 1564 0 R 1565 0 R/ON 1563 0 R 1566 0 R 1567 0 R]>>
endobj
1822 0 obj
<</Next 1823 0 R/S/Hide/T(STAFF_CS_txm)>>
endobj
1823 0 obj
<</H false/Next 1824 0 R/S/Hide/T(SUP_MGR_CS_txm)>>
endobj
1824 0 obj
<</Next 1825 0 R/S/Hide/T(STAFF_Comm#_txt)>>
endobj
1825 0 obj
<</Next 1826 0 R/S/Hide/T(STAFF_Comm_txm)>>
endobj
1826 0 obj
<</H false/Next 1827 0 R/S/Hide/T(SUP_MGR_Comm#_txt)>>
endobj
1827 0 obj
<</H false/Next 1828 0 R/S/Hide/T(MGR_Comm_txm)>>
endobj
1828 0 obj
<</Next 1829 0 R/S/Hide/T(SUP_Comm_txm)>>
endobj
1829 0 obj
<</Next 1830 0 R/S/Hide/T(SUP_StaffMgmt#_txt)>>
endobj
and on it goes . . .
Any help would be GREATLY appreciated!
Copy link to clipboard
Copied
That is not JavaScript, but rather the show/hide field definition dictionaries. Using JavaScript will be the easiest method. I wouldn't edit the document this way as it is easy to damage it.
You can make it MUCH easier on yourself if you use a hierachical naming convention for your fields by giving each field in a particular group the same prefix, delimited by a "." character. For example:
GROUP1.name
GROUP1.address
GROUP2.name
GROUP2.address
This lets you how/hide an entire group with a single JavaScript statement. For example:
// Show all of the GROUP1 fields
getField("GROUP1").display = display.visible;
// Hide all of the GROUP2 fields
getField("GROUP2").display = display.hidden;
Post again if you need more help.
Copy link to clipboard
Copied
That is not JavaScript, but rather the show/hide field definition dictionaries. Using JavaScript will be the easiest method. I wouldn't edit the document this way as it is easy to damage it.
You can make it MUCH easier on yourself if you use a hierachical naming convention for your fields by giving each field in a particular group the same prefix, delimited by a "." character. For example:
GROUP1.name
GROUP1.address
GROUP2.name
GROUP2.address
This lets you how/hide an entire group with a single JavaScript statement. For example:
// Show all of the GROUP1 fields
getField("GROUP1").display = display.visible;
// Hide all of the GROUP2 fields
getField("GROUP2").display = display.hidden;
Post again if you need more help.
Copy link to clipboard
Copied
George,
Thanks for the help. I do have prefixes for the various levels (MGR, SUP, STAFF), but was using underscores instead of periods to separate them.
Again, apologies for not having gotten to learning javascript yet . . . So, if I want to use the javascript editor within acrobat to make those commands you posted into a javascript that I can run as a button action, what else do I need to add? Is there some code that goes at the beginning and end of the script that makes it a script?
I have the same question re: a related post about using a script to limit a field's numerical entries to either 1 or 3. I can use GREP to describe the limitation but I don't know the syntax for the script.
Copy link to clipboard
Copied
I just responded to your other post, so see the reply there.
You don't need to add anything else, but you will need to change the field names so they use a period as a separator.
Copy link to clipboard
Copied
Out of curiosity, I am making a map with sub-maps as layers. Obviously, the catch is that the buttons show through. If I only wnat to see a single submap layer, and still be able to close it, without all of the other submap buttons showing through and confusing the image, could I use a simple variation of what you have above with an if/else statement such as:
if (this.getField("Clickable.Button").valueAsString!="ButtonClicked")
getField("Clickable.Button").display = display.hidden;
else if (this.getField("Clickable.Button").valueAsString=="ButtonClicked")
getField("Clickable.Button").display = display.visible;
So, disclaimer, the valueAsString bit was what I used to get some drop downs to work for me in another project. So, I realize that might not be right here. I am just wondering if I shouldn't just scrap this and go with linking individual PDF sheets to each button instead. (Which will be something else I will have to figure out, but that is a matter for later.)

