If statement Help

New Here ,
Feb 25, 2019

Copy link to clipboard

Copied

Hello all

I am need to using Acrobat for calculations and I am look for some help with an if statement this is what I am trying to do

I have an input box and I need to take what ever is put into that box and calculate and show that in the secound box, but I need it to not show anything in the second box if nothing is put in the first box. I hope this makes sense, this is the jave script I have and the calculation works but it will still do a calculation in no number is in the first box

these are the 2 boxes

input.PNG

in the calculation I have this script

event.value=((-(+this.getField("Input").value/3-6000)*(1.052-0.7778)/100))

Any help would be great and thanks in advance

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Change your code to this:

var v = this.getField("Input").valueAsString;

if (v=="") event.value = "";

else event.value=((-(Number(v)/3-6000)*(1.052-0.7778)/100));

TOPICS
Acrobat SDK and JavaScript

Views

46

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

If statement Help

New Here ,
Feb 25, 2019

Copy link to clipboard

Copied

Hello all

I am need to using Acrobat for calculations and I am look for some help with an if statement this is what I am trying to do

I have an input box and I need to take what ever is put into that box and calculate and show that in the secound box, but I need it to not show anything in the second box if nothing is put in the first box. I hope this makes sense, this is the jave script I have and the calculation works but it will still do a calculation in no number is in the first box

these are the 2 boxes

input.PNG

in the calculation I have this script

event.value=((-(+this.getField("Input").value/3-6000)*(1.052-0.7778)/100))

Any help would be great and thanks in advance

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Change your code to this:

var v = this.getField("Input").valueAsString;

if (v=="") event.value = "";

else event.value=((-(Number(v)/3-6000)*(1.052-0.7778)/100));

TOPICS
Acrobat SDK and JavaScript

Views

47

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
Feb 25, 2019 0
Most Valuable Participant ,
Feb 25, 2019

Copy link to clipboard

Copied

Change your code to this:

var v = this.getField("Input").valueAsString;

if (v=="") event.value = "";

else event.value=((-(Number(v)/3-6000)*(1.052-0.7778)/100));

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...
Feb 25, 2019 1