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

Help please with custom calc script comparing two dropdown value

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

Views

280

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
Community Expert ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

I miss one ( after if.

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

Copy link to clipboard

Copied

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

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

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
Community Expert ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

LATEST

You must use " not “ .

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