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

Multiple sets of Dependent dropdowns in DC Pro

New Here ,
Aug 10, 2018 Aug 10, 2018

Copy link to clipboard

Copied

Hi,

I am trying to modify a script for dependent dropdowns, and am running into some issues.  I have 4 drop downs.  Box 2 is dependent on Box 1 and Box 4 is Dependent on Box 3.  I can get Box 1 and 2 to populate and work; however when I try and add in the second set, it fails.  It will either populate the 4th box based on the 1st box or not work at all.

My Script is as follows.

myBox1Values = ["", "1st Choice", "2nd Choice", "3rd Choice", "4th Choice"];

myBox3Values = ["", "A Choice", "B Choice", "C Choice", "D Choice"];

this.getField("Box1").setItems(myBox1Values)

this.getFiled("Box3").setItems(myBox3Values)

var DeptData = { "1st Choice": ["1st Choice-SubChoice1","1st Choice-SubChoice2"],

"2nd Choice": ["2nd Choice-Subchoice1", "2nd Choice-Subchoice2"],

"3rd Choice": ["3rd Choice-Subchoice1", "3rd Choice-Subchoice2", "3rd Choice-Subchoice3"],

"4th Choice": ["4th Choice-Subchoice1", "4th Choice-Subchoice2"]

"A Choice": ["A Choice-SubChoice1","A Choice-SubChoice2"]

"B Choice": ["B Choice-SubChoice1","B Choice-SubChoice2"]

"C Choice": ["C Choice-SubChoice1","C Choice-SubChoice2"]

"D Choice": ["D Choice-SubChoice1","D Choice-SubChoice2"]

                };

function SetFieldValues(cDeptName)

{

  this.getField("Box2").setItems(DeptData[cDeptName]);

  this.getField("Box4").setItems(DeptData[cDeptName]);

}

This is paired with setting the field values for Box2 (in Box1)

if( event.willCommit )

{

   if(event.value == "")

    this.getField("Box2").clearItems();

   else

    SetFieldValues(event.value);

}

For Box4 (in Box3)

if( event.willCommit )

{

   if(event.value == "")

     this.getField("Box4").clearItems();

   else

    SetFieldValues(event.value);

}

What I cannot figure out is how to have two sets of dependent dropdowns in a single PDF using Adobe Acrobat DC Pro.  I've done research and can find examples of three boxes all based off the first box, but cannot find anything about Multiple sets of dependent dropdowns.

Any assistance would be grateful.

Thank you,

TOPICS
Acrobat SDK and JavaScript

Views

394

Translate

Translate

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 guidelines

correct answers 1 Correct answer

New Here , Aug 10, 2018 Aug 10, 2018

Hi!

So I went back and thought about this for a few minutes and tried something different.  I thought I was locked to using "DeptData" as a variable.  I didn't need to.

I just made two separate scripts and ensured they referred to the proper boxes and named the variables Box2Data and cBox2Name and the function SetBox2Values and then replicated it for Boxes 3 and 4 using Box4Data, cBox4Name and SetBox4Values respectively.

Also made sure the KeyStroke scripts were referenced correctly each to SetBox2

...

Votes

Translate

Translate
Community Expert ,
Aug 10, 2018 Aug 10, 2018

Copy link to clipboard

Copied

Is there any error message in the console?

Votes

Translate

Translate

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 guidelines
New Here ,
Aug 10, 2018 Aug 10, 2018

Copy link to clipboard

Copied

LATEST

Hi!

So I went back and thought about this for a few minutes and tried something different.  I thought I was locked to using "DeptData" as a variable.  I didn't need to.

I just made two separate scripts and ensured they referred to the proper boxes and named the variables Box2Data and cBox2Name and the function SetBox2Values and then replicated it for Boxes 3 and 4 using Box4Data, cBox4Name and SetBox4Values respectively.

Also made sure the KeyStroke scripts were referenced correctly each to SetBox2Values and SetBox4Values.

It works.

Here is the code

1st Set of Boxes

Script Name = SetBox2Values

myBox1Values = ["", "1st Choice", "2nd Choice", "3rd Choice", "4th Choice"];

this.getField("Box1").setItems(myBox1Values);

var Box2Data = { "1st Choice": ["1st Choice-SubChoice1","1st Choice-SubChoice2"],

"2nd Choice": ["2nd Choice-Subchoice1", "2nd Choice-Subchoice2"],

"3rd Choice": ["3rd Choice-Subchoice1", "3rd Choice-Subchoice2", "3rd Choice-Subchoice3"],

"4th Choice": ["4th Choice-Subchoice1", "4th Choice-Subchoice2"]

                };

function SetBox2Values(cBox2Name)

{

  this.getField("Box2").setItems(Box2Data[cBox2Name]);

}

and Box1's CustomKeyStroke Script (Commit selected value immediately is checked)

if( event.willCommit )

{

   if(event.value == "")

     this.getField("Box2").clearItems();

   else

    SetBox2Values(event.value);

}

Second Set of Boxes

Script Name = SetBox4Values

myBox3Values = ["", "A Choice", "B Choice", "C Choice", "D Choice"];

this.getField("Box3").setItems(myBox3Values);

var Box4Data = { "A Choice": ["A-SubChoice1","A-SubChoice2"],

"B Choice": ["B-Subchoice1", "B-Subchoice2"],

"C Choice": ["C-Subchoice1", "C-Subchoice2", "C-Subchoice3"],

"D Choice": ["4D-Subchoice1", "D-Subchoice2"]

                };

function SetBox4Values(cLevelRankName)

{

  this.getField("Box4").setItems(Box4Data[cBox4Name]);

}

and Box3's CustomKeyStroke Script (Commit selected value immediately is checked)

if( event.willCommit )

{

   if(event.value == "")

     this.getField("LevelRank").clearItems();

   else

    SetLevelRankValues(event.value);

}

Votes

Translate

Translate

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 guidelines