Hiding Form Fields Depending On Selection

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

81

Likes

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

Hiding Form Fields Depending On Selection

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

82

Likes

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

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Nov 22, 2017 0