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

Hiding Form Fields Depending On Selection

New Here ,
Nov 22, 2017 Nov 22, 2017

Copy link to clipboard

Copied

Hello all,

I'm currently in the process of creating a form with multiple different form fields and I only want certain fields to populate, based on what action the user selects from the primary field. I have been using the following script:

if (this.getField("Status Change").value == "Enter Value"){

event.target.display = display.visible;

}

else if (this.getField("Status Change").value == "Enter Value") {

event.target.display = display.visible;

}

else{

event.target.display = display.hidden;

}

This script does exactly what I need it to do, but since there are a bunch of different form fields in this document, I have to manually add this script to each form field under Calculate > Custom calculation script. I am looking for an easier way to do this if possible.

Thanks!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

213

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
Community Expert ,
Nov 22, 2017 Nov 22, 2017

Copy link to clipboard

Copied

LATEST

Since the value of one field (the source) is changing several other fields (the targets), it's best to put the code in the source field, i.e. "Status Change". So you are driving the action from the source of the change.

And don't use a calculate event. This event is called every time any field is changed, so they are called all the time and a lot of them will slow down the form.

Use the Keystroke or format event, it's only called once when the user changes the specific field.

Is the "Status Change" field a Combo Box (drop down list)? This article will help, it's about changing data in several fields from a selection in a dropdown, but can easily be modified to do what you want.

https://acrobatusers.com/tutorials/change_another_field

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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