How to show/hide a field based on another field.

New Here ,
Aug 02, 2018

Copy link to clipboard

Copied

I have the following document level script:

function Openn(){
        if(this.getField("cobuyer").value.length == 0)
        {
           this.getField("xcobuy").display = display.hidden;
        }

     else
        {
            this.getField("xcobuy").display = display.visible;
        }

                }
Openn();

I am getting the following error:

Acrobat EScript Built-in Functions Version 10.0
Acrobat SOAP 10.0

TypeError: this.getField("xcobuy") is null
9:Document-Level:Openn

The form is being produced with the data already in it and that field is not null

Thanks

Jasper

TOPICS
Acrobat SDK and JavaScript, Windows

Views

106

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

How to show/hide a field based on another field.

New Here ,
Aug 02, 2018

Copy link to clipboard

Copied

I have the following document level script:

function Openn(){
        if(this.getField("cobuyer").value.length == 0)
        {
           this.getField("xcobuy").display = display.hidden;
        }

     else
        {
            this.getField("xcobuy").display = display.visible;
        }

                }
Openn();

I am getting the following error:

Acrobat EScript Built-in Functions Version 10.0
Acrobat SOAP 10.0

TypeError: this.getField("xcobuy") is null
9:Document-Level:Openn

The form is being produced with the data already in it and that field is not null

Thanks

Jasper

TOPICS
Acrobat SDK and JavaScript, Windows

Views

107

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
Aug 02, 2018 0
Most Valuable Participant ,
Aug 02, 2018

Copy link to clipboard

Copied

That means the field name you entered is incorrect. Make sure you spell it EXACTLY as it appears on the page, including lower/upper-case letters.

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...
Aug 02, 2018 0
New Here ,
Aug 02, 2018

Copy link to clipboard

Copied

Thanks for the reply.

I copied/paste the name of the field.  It is exactly what is on the form.

SNAG_Program-0002.jpg

Thanks,

Jasper

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...
Aug 02, 2018 0
New Here ,
Aug 02, 2018

Copy link to clipboard

Copied

Is it possible that I may need to add a delay to the routine?

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...
Aug 02, 2018 0
Most Valuable Participant ,
Aug 02, 2018

Copy link to clipboard

Copied

Shouldn't be necessary... Can you share the file with us (via Dropbox, Google Drive, Adobe Send & Track, etc.)?

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...
Aug 02, 2018 0
New Here ,
Aug 02, 2018

Copy link to clipboard

Copied

File loaded to OneDrive.

Here is the link:

Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

Filename MV-PowerofAttorney,.pdf

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...
Aug 02, 2018 0
try67 LATEST
Most Valuable Participant ,
Aug 02, 2018

Copy link to clipboard

Copied

Works fine for me... However, there's no need to use a doc-level script for it. You can use the Validation script of the "cobuyer" field, instead. That way it will also work if someone changes the field's value after opening the file. Use this code:

if (event.value.length == 0) {

    this.getField("xcobuy").display = display.hidden;

} else {

    this.getField("xcobuy").display = display.visible;

}

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...
Aug 02, 2018 0