Highlighted

Making one fillable field print or not print based upon whether there is an entry in a second field

Community Beginner ,
Oct 30, 2020

Copy link to clipboard

Copied

I have a state supplied PDF fillable form. In one section it is designed to allow the user list  six events in a column. An event take  the form of "Charge:_[fillable field]__."

Perhaps trying to be too cute, I have squeezed in an additional field below the standard six. If  the user has seven charges it will save her having to fill out a second form.  However, I don't want the field to show unless it is used.

It is "_[filable field1]_  _[filable field2]_." I have set it so that when the user puts something in Field2, the word Charge is entered in Field1.

I did this with this script in the Custom Calculate tab of Field1

if (this.getField("Text2").valueAsString.length == 0 ) this.event.value= " "; else this.event.value= " CHARGE"

However I would like the word "Charge" to appear in Field1 even before there is an entry in Field2, but just  not be printed if there is no entry in Field2. I have tried putting "Charge" in the Default Value in Field1 and using this code in Custom calculation (the General Tab is set to "visible"):

if (this.getField("Text2").valueAsString.length == 0 ) this.event.display = display.noPrint; else this.event.display = display.visible;

Nothing Happens. It prints the default all the time.

Stay safe and thank you in advance.

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Change:

this.event.display

To:

event.target.display

TOPICS
PDF forms

Views

29

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

Making one fillable field print or not print based upon whether there is an entry in a second field

Community Beginner ,
Oct 30, 2020

Copy link to clipboard

Copied

I have a state supplied PDF fillable form. In one section it is designed to allow the user list  six events in a column. An event take  the form of "Charge:_[fillable field]__."

Perhaps trying to be too cute, I have squeezed in an additional field below the standard six. If  the user has seven charges it will save her having to fill out a second form.  However, I don't want the field to show unless it is used.

It is "_[filable field1]_  _[filable field2]_." I have set it so that when the user puts something in Field2, the word Charge is entered in Field1.

I did this with this script in the Custom Calculate tab of Field1

if (this.getField("Text2").valueAsString.length == 0 ) this.event.value= " "; else this.event.value= " CHARGE"

However I would like the word "Charge" to appear in Field1 even before there is an entry in Field2, but just  not be printed if there is no entry in Field2. I have tried putting "Charge" in the Default Value in Field1 and using this code in Custom calculation (the General Tab is set to "visible"):

if (this.getField("Text2").valueAsString.length == 0 ) this.event.display = display.noPrint; else this.event.display = display.visible;

Nothing Happens. It prints the default all the time.

Stay safe and thank you in advance.

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Change:

this.event.display

To:

event.target.display

TOPICS
PDF forms

Views

30

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
Oct 30, 2020 0
Most Valuable Participant ,
Oct 30, 2020

Copy link to clipboard

Copied

Change:

this.event.display

To:

event.target.display

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...
Oct 30, 2020 0
Community Beginner ,
Oct 30, 2020

Copy link to clipboard

Copied

BINGO!!!!

How would I know to do that?  

You didn't use it here:

https://community.adobe.com/t5/acrobat/is-it-possible-to-set-form-fields-to-only-print-when-they-re-...

Thaks again and stay safe.

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...
Oct 30, 2020 0
Most Valuable Participant ,
Oct 30, 2020

Copy link to clipboard

Copied

You need to learn how Acrobat JS refers to events and fields in order to know how to do it correctly.

I never used this.event in my code...

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...
Oct 30, 2020 0
KYJud LATEST
Community Beginner ,
Oct 30, 2020

Copy link to clipboard

Copied

I was thinking about the "target"

I won't take up any more of your time. No need to respond.

Thanks--Again

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...
Oct 30, 2020 0