Use Acrobat JavaScript to Calculate a Risk Rating from Two Dropdowns
Question details
Create a PDF form calculation that returns a risk rating based on likelihood and consequence dropdown selections.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form contains two dropdowns and a rating field that should display the result of a risk matrix.
- Observed behavior
- The rating field should show a value such as Very Low, High, or Extreme for a complete selection and remain blank when no combination matches.
Open the PDF in an Acrobat edition that can edit forms, and identify the exact field names and export values of both dropdowns. Prepare your risk matrix so you can assign the correct rating to each combination.
Add a Custom Calculation Script to the Rating Field
Use dropdown export values to look up a rating whenever the form recalculates.
The example uses likelihood export values A through E and consequence export values 1 through 5. It assigns the same rating to every letter in each numbered group, so change the cases to match your actual risk matrix if likelihood should affect the result.
In Acrobat, open All tools > Prepare a form. Open each dropdown's Properties and check its name and the export values on the Options tab. The example uses fields named Dropdown1 and Dropdown2; its unselected options should have blank export values.
In Prepare a form, open Properties for the Rating text field. Select the Calculate tab, choose Custom calculation script, and click Edit.
Paste the following script into the JavaScript editor. Replace the field names and case mappings if your form uses different names or risk levels: var likelihood = this.getField("Dropdown1").valueAsString; var consequence = this.getField("Dropdown2").valueAsString; var key = likelihood + consequence; event.value = ""; if (likelihood !== "" && consequence !== "") { switch (key) { case "A1": case "B1": case "C1": case "D1": case "E1": event.value = "Very Low"; break; case "A2": case "B2": case "C2": case "D2": case "E2": event.value = "Low"; break; case "A3": case "B3": case "C3": case "D3": case "E3": event.value = "Medium"; break; case "A4": case "B4": case "C4": case "D4": case "E4": event.value = "High"; break; case "A5": case "B5": case "C5": case "D5": case "E5": event.value = "Extreme"; break; } }
Close the script editor and field Properties, then save the PDF. Select different combinations in both dropdowns and confirm that Rating shows the expected result; also test blank and unmapped selections.

View and Work with PDF Documents in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and support for common document formats, making it easy to move between Office files and PDFs. Use Acrobat to author and test this custom JavaScript calculation; support for such scripts varies by PDF viewer.

Frequently Asked Questions
Where do I find a dropdown's export values in Acrobat?
Open All tools > Prepare a form, open the dropdown's Properties, and select the Options tab. Check the export value assigned to each item and use those values in the script's cases.
Why does the rating stay blank after I make selections?
Check that Dropdown1 and Dropdown2 match the exact field names and that their export values form a listed case, such as A1. An unmatched combination or a blank selection leaves event.value empty.
How do I make likelihood affect the rating?
Edit the custom calculation script on the Rating field's Calculate tab. Move individual cases, such as A4 or E4, under the rating required by your risk matrix rather than assigning every letter in a numbered group the same result.
Will the calculation work in every PDF viewer?
Not necessarily. PDF viewers differ in their support for Acrobat JavaScript and form calculations, so test the saved PDF in the viewer your recipients will use.




