Help please with custom calc script comparing two dropdown value

New Here ,
Nov 06, 2019

Copy link to clipboard

Copied

Hello everyone,

 

So I'm tring to create a custom calc script wherein two dropdowns (selection for unit values, e.g. mg/mL vs ug/mL) have their values selected by the user. The user also fills in numbers for other fields. Then calculations using those other fields are performed to return an answer to yet another field.

 

Here is my sloppy prelim version (I just started learning this java stuff 2 days ago, so please bear with me):

 

if (this.getField("Dropdown8").value=="mg/mL") && (this.getField(“Dropdown88”).value==”ug/mL”)) event.value = (this.getField("mls8").value*this.getField("useat8").value/this.getField("stock8").value/1000).toFixed(2)

 

Such that if units for one field are selected as mg/mL and units for the other field are selected as micrograms per mL (ug/mL) then the target field performs that ridiculous calculation and returns it to 2 decimal points.

 

I just get syntax errors the whole time.  Thanks in advance for the help!

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

66

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

Help please with custom calc script comparing two dropdown value

New Here ,
Nov 06, 2019

Copy link to clipboard

Copied

Hello everyone,

 

So I'm tring to create a custom calc script wherein two dropdowns (selection for unit values, e.g. mg/mL vs ug/mL) have their values selected by the user. The user also fills in numbers for other fields. Then calculations using those other fields are performed to return an answer to yet another field.

 

Here is my sloppy prelim version (I just started learning this java stuff 2 days ago, so please bear with me):

 

if (this.getField("Dropdown8").value=="mg/mL") && (this.getField(“Dropdown88”).value==”ug/mL”)) event.value = (this.getField("mls8").value*this.getField("useat8").value/this.getField("stock8").value/1000).toFixed(2)

 

Such that if units for one field are selected as mg/mL and units for the other field are selected as micrograms per mL (ug/mL) then the target field performs that ridiculous calculation and returns it to 2 decimal points.

 

I just get syntax errors the whole time.  Thanks in advance for the help!

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

67

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
Nov 06, 2019 0
Adobe Community Professional ,
Nov 06, 2019

Copy link to clipboard

Copied

I miss one ( after if.

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...
Nov 06, 2019 0
New Here ,
Nov 06, 2019

Copy link to clipboard

Copied

I added the ( after if and still get syntax error: illegal character 1: at line 2

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...
Nov 06, 2019 0
New Here ,
Nov 06, 2019

Copy link to clipboard

Copied

After removing the second condition (after the &&) the editor accepted the script.  It seems as though the && part is what's giving it trouble...

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...
Nov 06, 2019 0
Adobe Community Professional ,
Nov 06, 2019

Copy link to clipboard

Copied

You must use " not “ .

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...
Nov 06, 2019 0