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

Creating Form Field Groups in Acrobat Professional 8.2.5 for Mac

dford
Registered: Nov 30 2010
Posts: 8
Answered

Hi everyone,
 
I am creating some in-depth forms using Acrobat Pro for Mac and I am finding this process very tedious and fear I am just mis-using the tools at my disposal.
 
I'm creating a form that as you select certain parameters it opens (unhides) fields and vice versa.
 
Currently I am showing and hiding fields by creating actions (on mousedown) when certain parameters are selected. This becomes very tedious when you want to show and hide many fields, dropdowns, because you need to select each field, title, or dropdown menu individually.
 
Is there a better way to achieve this, perhaps creating all the fields and grouping them, then showing and hiding the group instead of individual fields?!
 
Any help would be greatly appreciated!
  
Thanks,
  
Dev
  

My Product Information:
Acrobat Pro, Macintosh
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
You should use the Mouse Up event rather than the Mouse Down, but that has nothing to do with your problem.

If you use a hierarchical naming scheme, it becomes easier to show/hide groups of fields by using JavaScript. For example, suppose you have 100 text fields named "T1.0", "T1.1", ... "T1.99". You can then control all at once with something like the following JavaScript:

// Hide all of the T1 fields
getField("T1").display = display.hidden;
dford
Registered: Nov 30 2010
Posts: 8
Hi George...

Thanks for posting back...

I was worried you would suggest something like this...I guess there is no user friendly GUI that is built in rather than using Javascript? These are an interim solution to a full HTML based form in the future. I was hoping to avoid the programming until then...No go?

Thanks,


Dev
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I'm afraid so. The scripting for what you want is really very simple and straightforward. Post again if you'd like more help with it.
dford
Registered: Nov 30 2010
Posts: 8
Thanks again George!

I might give that a shot...Unfortunately I am about 30% of the way thru the form already, so going back and renaming might cause some more issues...

Is the JS as simple as GetField calls as mentioned above?

Thanks,


Dev
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
dford wrote:
Is the JS as simple as GetField calls as mentioned above?

Yep. To show the fields:

getField("T1").display = display.visible;

dford
Registered: Nov 30 2010
Posts: 8
Great!

and getField("T1").hidden = display.hidden

Thanks,


Dev
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Accepted Answer
dford wrote:
getField("T1").hidden = display.hidden

No, it's:

getField("T1").display = display.hidden


dford
Registered: Nov 30 2010
Posts: 8
Thanks George!

I noticed that in your first post back...

Thanks again for following up - I will try this out and let you know!


Thanks,


Dev
dford
Registered: Nov 30 2010
Posts: 8
Your right...

That is approximately 1000 times easier than my method.

George, you are a gentleman and a scholar - Thanks for the support..



Dev
dford
Registered: Nov 30 2010
Posts: 8
Hey George,

If I could bug you once again, is there an easy way in JS to show a range of fields and hide another range - I am using your consecutive naming convention as we chatted about before?

I have tried the following:

getField("T1"-"T6").display = display.hidden

but JS is unable to establish a field...

Thanks in advance,



Dev
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You will need to either create a statement for each field or create a controlled loop to go through the fields either by the exact field name or a computed field name.

// create a control loop to process "T" + i field names
// for i = 1 to 6
for(i = 1; i < 7; i++) {
// hide field name "T" + i
this.getField("T" + i).display = display.hidden;
} // end control loop

George Kaiser

dford
Registered: Nov 30 2010
Posts: 8
Oh another George!

To be more specific I have fields numbered similar to what the George Johnson suggested in the above thread.

S2.1, S2.2, S2.3, S2.4, S2.5, etc.

Some others like:

S3.1, S3.2, S3.3, S3.4, S3.5, etc.

On a single form check box, I would like to show the a range of S2's and hide a range of S3's.

Would your script pertain to my goal? I performed a copy and paste, and I appear to be getting:

"SyntaxError: missing ; after for-loop initializer 3:"

Strange because the error is on a comment?!?! I did change the "T's" to "S's" in order to work with my naming convention...

I am very new at JS...

Thanks,


Dev


gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
It does when the field names "T1", "T2, "T3", "T4", "T5", and "T6" exist. The exact code will very much depend upon your field names. Acrobat JavaScript is not coding by example. If you naming is truly hierarchical, then there is a briefer version that can be used, otherwise you will need to specify each field name to be processed.

If your fields have a very strict hierarchial naming structure then:

// hide all fields with a name like "S2.#"
this.getField("S2").display = display.hidden;

If you do not want to include all of the fields, you will need to specify each field name to be porcessed.

// create an array of field names to process
var aFieldNames = new Array("S2.1", "S2.2", "S2.3");
// process each element of array
for(i = 0; i < aFieldNames.length; i++) {
// hide field name i
this.getField(aFieldNames[i]).display = display.hidden;
}

George Kaiser