Skip to main content
New Participant
May 16, 2023
Answered

How to return a text value based on selections in two drop down menus?

  • May 16, 2023
  • 1 reply
  • 2553 views

Hi, I am totally new to Acrobat pro and I'm working on my first ever fillable pdf. 

I'm wondering if anyone can assist me with a custom calculation script to calculate a risk rating please?

I have 3 drop down boxes, "Likelihood", "Consequences", and "Risk Rating". I want Risk Rating to return a value per the picture below, based on the selected values in "Likelihood", "Consequences". Eg, if "1 (Rare)" is selected in "Likelihood" and "1 (Insignificant)" is selected in "Consequences", then I want "Risk Rating" to return the text value "LOW".

I can't seem to fgure it out! Thanks in advance 🙂 

 

 

 

This topic has been closed for replies.
Correct answer Nesa Nurani

Thank you - I think I am getting closer but it is still giving a syntax error?

 


You are using extra ( after every &&, just use parenthesis at the start and end of condition:

if(L=="1 (RARE)" && (C=="1 (INSIGNIFICANT)"||L=="1 (RARE)" && (C=="2 (MINOR)"||L=="1 (RARE)"...etc

 

1 reply

Nesa Nurani
Inspiring
May 16, 2023

Change "Risk Rating" field from dropdown to text field, and take a look at this:

https://community.adobe.com/t5/acrobat-discussions/risk-calculation-matrix/m-p/13779239#M411070 

New Participant
May 16, 2023

Yeah I did already look at that but I can't get it to work since that is a table and mine is a picture. 

I tried below to start with but its saying "syntax error: missing) after condition" 

 

var L = this.getField("Likelihood").valueAsString;
var C = this.getField("Consequences").valueAsString;

if(L=="1 (RARE)" and (C=="1 (INSIGNIFICANT)"||L=="1 (RARE)" and (C=="2 (MINOR)"||L=="1 (RARE)" and (C=="3 (MEDIUM)"||L=="2 (UNLIKELY)" and (C=="1 (INSIGNIFICANT)"||L=="2 (UNLIKELY)" and (C=="2 (MINOR)"||L=="3 (POSSIBLE)" and (C=="3 (MEDIUM)")
event.value = "LOW";
else
event.value = "";

Nesa Nurani
Inspiring
May 16, 2023

For 'and' use &&