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

How to show/hide "field Z" if "field Y" is within 10 digits of "field X"?

New Here ,
Jun 20, 2017 Jun 20, 2017

Copy link to clipboard

Copied

I'm trying to create a form that determines if a patient requires a particular lab based on their history. "field X" is the patient's age and "field Y" is another age. I'm trying to create a script that determines if "field Y" is plus or minus 10 years of the age in "field X". If it is within 10 years I want "field Z" to show. If the age isn't within 10 years, then I want "field Z" to remain hidden.

I'd appreciate any help with this. I'm almost done with this form and it's looking great so far. Thanks in advance!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

300

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

correct answers 1 Correct answer

Community Expert , Jun 20, 2017 Jun 20, 2017

Enter this code as the custom calculation script of "Z":

var x = this.getField("X").valueAsString;

var y = this.getField("Y").valueAsString;

if (x=="" || y=="") event.target.display = display.hidden; // if either field is empty, hide this field

else event.target.display = (Math.abs(Number(x)-Number(y))<10) ? display.visible : display.hidden;

Votes

Translate

Translate
Community Expert ,
Jun 20, 2017 Jun 20, 2017

Copy link to clipboard

Copied

Enter this code as the custom calculation script of "Z":

var x = this.getField("X").valueAsString;

var y = this.getField("Y").valueAsString;

if (x=="" || y=="") event.target.display = display.hidden; // if either field is empty, hide this field

else event.target.display = (Math.abs(Number(x)-Number(y))<10) ? display.visible : display.hidden;

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

Copy link to clipboard

Copied

LATEST

Thanks! This worked perfectly.

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