These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Show / Hide Multiple Fields

nkaspar
Registered: Sep 20 2008
Posts: 6

Hello. I am using Acrobat Pro 8 for Mac and I am looking to use the Show / Hide function to control the visability of a series of fields. Right now I am applying the show / hide function to each field individually when I set up a Show/Hide button. That is very time consuming.
Is there a way to select a series of fields all at once (similarly to how you do it in a calculation function) and the apply the show or hide feature to it. Any tips would be most appreciated.
Thank you.
Norbert Kaspar

My Product Information:
Acrobat Pro 8.0, Macintosh
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
To answer your question, no.

But you might consider using JavaScript. If your fields follow a hierarchical naming scheme, you can use a single line of code to show/hide a series of fields. For example, suppose you have a series of fields named "text1.0", "text1.1", "text1.2", ..."text1.9". You could hide all ten fields by doing:

// Hide the text1 fields
getField("text1").display = display.hidden;


Or you can show all ten fields:

// Show the text1 fields
getField("text1").display = display.visible;


To set up a button to toggle the visibility of such a series of fields:

if (getField("Text1.0").display === display.hidden) {
getField("Text1").display = display.visible;
} else {
getField("Text1").display = display.hidden;
}


If you don't want to change your field names you can use a series of statements:

// Hide these fields
getField("text1").display = display.hidden;
getField("text2").display = display.hidden;
getField("text3").display = display.hidden;
getField("text4").display = display.hidden;
getField("text5").display = display.hidden;


or set up a loop if the fields names allow:

for (var i = 1; i < 6; i++) {
getField("text" + i).display = display.hidden;
}


or use an array of field names:

// Create an array of field names
var field_array = ["firstname", "lastname", "address"];

// Loop through field names in array and set fields to hidden
for (var i = 0; i < field_array.length; i +=1) {
getField(field_array[i]).display = display.hidden;
}


As you can see, there are a number of approaches you can take, and you can make it easier by using particular field naming schemes.


George
nkaspar
Registered: Sep 20 2008
Posts: 6
Thank you for your very quick reply George. It is appreciated. Your solution has possibilities for my situation. I will explore this further.
Again - thank you.
Norbert