• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Group fields for more compact scripting (visible/hidden)

Contributor ,
Dec 29, 2017 Dec 29, 2017

Copy link to clipboard

Copied

As a fledgling scripter, I'm creating a PDF form that acts as a calculator from which lay-user can compare a few similar consumer products based a couple variable choices they may make. Within the form, I have built a hidden input form to which a [non-developer] Admin can adjust the data in fields of each of the displayed choices before hiding the input form and distributing to the intended lay-users who would use the calculator to make consumer choices. This whole project is coming along nicely, as I intended. But, my question...

Is it possible to "group" fields in a way that would allow me to treat them as one for the purpose of making visible or hidden? Example, in that hidden Admin-input form, each of 4 potential products has, say, 25 fields in which the calculable source data may be changed by Admin before distribution. So, currently, if I have 4 products to compare, I have 100 individual fields to make visible/hidden based on Admin's password field and button. My current script makes each of the 100 fields visible/hidden, fine. But, it would be so much easier if, say, product No. 1's 25 respective fields could be named "fieldGroup1" and then script the visible/hidden functions with just that one group field name instead of the tedious scripting and calling all 25 individual fields in a block of script.

Hope this is clear - and much thanks to any ideas (or, even if I'm told it cannot be done).

TOPICS
Acrobat SDK and JavaScript , Windows

Views

671

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 29, 2017 Dec 29, 2017

Yes, it's possible to group fields by naming them like this:

Group1.Field1

Group1.Field2

Group1.Field3

You can then access all the fields in the group like this:

this.getField("Group1")

Or a specific field like this:

this.getField("Group1.Field2")

Votes

Translate

Translate
Community Expert ,
Dec 29, 2017 Dec 29, 2017

Copy link to clipboard

Copied

Yes, it's possible to group fields by naming them like this:

Group1.Field1

Group1.Field2

Group1.Field3

You can then access all the fields in the group like this:

this.getField("Group1")

Or a specific field like this:

this.getField("Group1.Field2")

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 30, 2017 Dec 30, 2017

Copy link to clipboard

Copied

Wow. Thank you! This is much simpler and logical than I expected!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 29, 2017 Dec 29, 2017

Copy link to clipboard

Copied

If you create on field and then use the "Create Multiple Copies" the fields will automatically have a dot number value starting at zero applied to each field name starting with the selected field and through the number of fields created. This form of naming field is known as hierarchical field naming. The parent field is the field name without the suffix can can be accessed like any field. Any change to a common property of the field will change all the fields, children, under this field. It is also possible to create an array of the children fields using ".getArray()" method. Using this array will allow one to access is child field object as an individual field which is useful when using a for loop to step through a group of fields.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 30, 2017 Dec 30, 2017

Copy link to clipboard

Copied

LATEST

Thank you! This will cut the development time into fractions (especially for this noob)!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines