AND ... OR type functions in scripting? Double IF'ing?

New Here ,
Jan 20, 2020

Copy link to clipboard

Copied

Hello again all,

 

I have a field that calculates something. It works.

 

a sample line...

 

if (this.getField("Dropdown2.15.2").value=="ASTRODYNAMICS")event.value = ( this.getField("INTELLECT").value + this.getField("INTELLECT").value ) + this.getField("WILL").value;

 

However, I want to also add exactly 10 more if FieldA="MyTEXTValue". How would I do this?

 

Thanks very much

 

 

 

 

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

51

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

AND ... OR type functions in scripting? Double IF'ing?

New Here ,
Jan 20, 2020

Copy link to clipboard

Copied

Hello again all,

 

I have a field that calculates something. It works.

 

a sample line...

 

if (this.getField("Dropdown2.15.2").value=="ASTRODYNAMICS")event.value = ( this.getField("INTELLECT").value + this.getField("INTELLECT").value ) + this.getField("WILL").value;

 

However, I want to also add exactly 10 more if FieldA="MyTEXTValue". How would I do this?

 

Thanks very much

 

 

 

 

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

52

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
Jan 20, 2020 0
Most Valuable Participant ,
Jan 20, 2020

Copy link to clipboard

Copied

Yes, all of that is possible. You should study the core JS-syntax, but basically you do it like this:

 

AND:

if (condition1 && condition2 && condition3) { do action }

 

OR:

if (condition1 || condition2 || condition3) { do action }

 

Combined operators in a single if-statement:

if (condition1 || (condition2 && condition3)) { do action }

 

If-else if-else structure:

if (condition1) { do action1}

else if (condition2) {do action2}

else if (condition3) {do action3}

else {do default action}

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...
Jan 20, 2020 0
New Here ,
Jan 20, 2020

Copy link to clipboard

Copied

Thank you Try67. 

 

I have tried to find a list of commands and such for acrobat javascript, but it isnt easy to find surpringly. I am trying w3schools.com for it. Any other place I should look?

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...
Jan 20, 2020 0
try67 LATEST
Most Valuable Participant ,
Jan 20, 2020

Copy link to clipboard

Copied

The Acrobat JS documentation doesn't contain information about core-JS function. The W3Schools site is a good resource, but you have to make sure to only use the core stuff, ie nothing browser-related, as those commands won't work in Acrobat.

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...
Jan 20, 2020 0