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

Need help with javascript that turns ON one Layer that corresponds to a name in a drop down menu and turns off the layers of all other names.

New Here ,
Jun 25, 2017 Jun 25, 2017

I'm creating a pdf that will show the same stats for different subcontractors.

I would like to have all the subcontractor names in a drop down menu. When a subcontractor's name is chosen, a layer will be turned on that consists of a text field with the sub's stats.

All of the different subcontractor text fields will be located in the same place on the pdf, each with it's own layer. So that when a sub is chosen his layer is made visible and all of the rest are made invisible, until their name is chosen on the drop down menu.

Can this be done by adding script to the custom validation window under the drop down menu's properties section? If so, does anyone know what that script would be?

TOPICS
Acrobat SDK and JavaScript
274
Translate
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
Community Expert ,
Jun 26, 2017 Jun 26, 2017

Are these actually text fields or just text on the page. Text fields can be assigned to layers in PDF but there's no mechanism in Acrobat to do it. You'll need a plugin to set that up. If it's just text on (in?) a layer, then you can see code to do that sort of thing at the link below.

turn layers (OCG) on or off denpending on the resulat of a calculation (JavaScript)

Translate
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
New Here ,
Jun 26, 2017 Jun 26, 2017

Good distinction. I spoke incorrectly. These are not "text fields", it's just text on the page. Sorry about that.

So I looked at the link you provided and I get how that would work if the use was entering a number in, but what if I'm using a drop down menu with names instead? Do i assign each name a number in the "export value" box and do it that way?

Thanks for the help btw.

Translate
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
Community Expert ,
Jun 26, 2017 Jun 26, 2017
LATEST

You may find the coding easier if you set the export values in the list to correspond numerically to the index number of the OCGs in the array but any programming trick that will allow you to associate a value in the list to a certain layer name or index value should work.

For this sort of thing, I tend to put the script that does the work in a custom format script. That's generally not what the format script is used for but I use it because it's always the last event to get triggered before the user exits the field. You wouldn't modify the format of the field in your code, you'd just change the layer properties.

Translate
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