Skip to main content
Participant
November 6, 2019
Question

Help please with custom calc script comparing two dropdown value

  • November 6, 2019
  • 2 replies
  • 510 views

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!

This topic has been closed for replies.

2 replies

Participant
November 6, 2019

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

Bernd Alheit
Community Expert
Community Expert
November 6, 2019

You must use " not “ .

Bernd Alheit
Community Expert
Community Expert
November 6, 2019

I miss one ( after if.

Participant
November 6, 2019

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