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

Need help autopopulating a dropdown based on the selections from other 2 dropdowns

Community Beginner ,
Dec 12, 2024 Dec 12, 2024

Hello,

I am new to javascript. I followed a tutorial to be able to autopopulate a dropdown based on another, but I don't know how to make it work based on the selections of two dropdowns.

ejemplo.png

I have 7 options in the first column (discipline), and 5 levels in the second column (level). Depending on what is selected in those two, I need to auto populate different options in the third row (power).

¿Could someone help me with that?

TOPICS
How to , JavaScript , PDF , PDF forms
112
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Dec 12, 2024 Dec 12, 2024
LATEST

You can use something like this as custom calculation script of 3rd dropdown, change choices with actual values:

if (event.source && (event.source.name=="row1.discipline" || event.source.name=="row1.level")) {
var d1 = this.getField("row1.discipline").valueAsString;
var d2 = this.getField("row1.level").valueAsString;

if(d1 == "Choice1" && d2 == "Choice2")
event.target.setItems(["Choice1", "Choice2", "Choice3"]);
else if(d1 == "Choice2" && d2 == "Choice2")
event.target.setItems(["Choice4", "Choice5", "Choice6"]);
else
event.target.clearItems();}

View solution in original post

Translate
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 ,
Dec 12, 2024 Dec 12, 2024
LATEST

You can use something like this as custom calculation script of 3rd dropdown, change choices with actual values:

if (event.source && (event.source.name=="row1.discipline" || event.source.name=="row1.level")) {
var d1 = this.getField("row1.discipline").valueAsString;
var d2 = this.getField("row1.level").valueAsString;

if(d1 == "Choice1" && d2 == "Choice2")
event.target.setItems(["Choice1", "Choice2", "Choice3"]);
else if(d1 == "Choice2" && d2 == "Choice2")
event.target.setItems(["Choice4", "Choice5", "Choice6"]);
else
event.target.clearItems();}
Translate
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