# Calculation Setup

Community Beginner ,
Feb 24, 2021 Feb 24, 2021

Copied

Hi, is it possible to setup a form as per my example below?

I have 3 dropdowns (Course, Course Duartion and Course Code).

I would like to have it so the outcome of the course code selection is determinded by the choices selected on Course and Course duration.

For examples If you choose course A and a duration of 1 day, it auto selects Code A from the dropdown list options.

CODE + DURATION = CODE

A + 1 day = code A

A + half day = code b

B  + 1 day = code c

and so on. Does thatc make sense and can it be done?

TOPICS
Comment review and collaborate PDF, Create PDFs, Edit and convert PDFs, General troubleshooting, PDF forms

Views

72

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Adobe Community Professional , Feb 24, 2021 Feb 24, 2021
You can use something like this as "Custom calculation script" of 3rd dropdown (Course code):var c1 = this.getField("Course").valueAsString; var c2 = this.getField("Course Duration").valueAsString; if(c1 == "A" && c2 == "1 day") event.value = "Code A"; else if(c1 == "A" && c2 == "half day") event.value = "Code B"; else if(c1 == "B" && c2 == "1 day") event.value = "Code C"; else event.value = ""; If you don't select choices from 3rd dropdown manually you can use text field instead.

Likes

Adobe Community Professional , Feb 24, 2021 Feb 24, 2021
Did you check "commit selected value immediately" in dropdown properties -> options tab?Also check if all field names and values are correctly spelled.If you still have problems share your file here or send it to me via PM and Il take a look into it.

Likes

5 Replies 5
Feb 24, 2021 Feb 24, 2021

Copied

You can use something like this as "Custom calculation script" of 3rd dropdown (Course code):

var c1 = this.getField("Course").valueAsString;
var c2 = this.getField("Course Duration").valueAsString;
if(c1 == "A" && c2 == "1 day")
event.value = "Code A";
else if(c1 == "A" && c2 == "half day")
event.value = "Code B";
else if(c1 == "B" && c2 == "1 day")
event.value = "Code C";
else event.value = "";

If you don't select choices from 3rd dropdown manually you can use text field instead.

Likes

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 Beginner ,
Feb 24, 2021 Feb 24, 2021

Copied

Perfect, I'll give this a go and let you know.

Thank you!

Likes

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 Beginner ,
Feb 24, 2021 Feb 24, 2021

Copied

This seems to be working, but it will only populate the last option.

For instance on your example above it won't populate the value of Code A but only Code B.

You also have to select the text field to generate the info. Can it auto-populate the results by any chance?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 24, 2021 Feb 24, 2021

Copied

Did you check "commit selected value immediately" in dropdown properties -> options tab?

Also check if all field names and values are correctly spelled.

If you still have problems share your file here or send it to me via PM and Il take a look into it.

Likes

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 Beginner ,
Feb 25, 2021 Feb 25, 2021

Copied

LATEST

Hi Nesa,

Thank you thats now working,.

The issue was else event.value = ""; at the end of the orginal code. Once i removed that, it worked fine and when I set commit selected as per above, that worked fine as well.

Thank you for your help, its greatly appreciated,

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources