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

Dependent dropdown menus in Acrobat forms

New Here ,
Dec 06, 2018 Dec 06, 2018

Copy link to clipboard

Copied

I am creating a form that has 2 dependent dropdowns.  The first box has 4 choices.  The second one will vary depending on the 1st.  I am new to java, so I copied a script and edited it.  I am receiving an error when trying to apply my script.  The error and the script and both below.  Please help!  Thanks!

Acrobat Standard DC

Win 10 Enterprise

Here is my script:

++++++++++++++++++++++

myDropdown4Values = ["","Profitable growth", "Optimal outcomes", "Top talent", "Operational excellence"];

this.getField("Dropdown5").setItems(myDropdown4Values);

var Strategy = {

Profitable growth: ["","Diversification","Differentiation","Sales pipeline","Existing product innovation","New product innovation","Geographical expansion"],

Optimal outcomes: ["","Access","Quality","Risk Score Accuracy","Comprehensive Health","Utilization Management","Data Interfaces","Provider Collaboration","Individual Engagement","Stakeholder Satisfaction"],

Top talent: ["","Diversity and Inclusion","Culture and Infrastructure","Talent Management","Talent Recruitment","Talent Development","Thought Leadership","Learning and Growth"],

Operational excellence: ["","Go-to-Market Discipline","Security & Compliance","Cross-Functional Optimization","Data Analytics","Customer Service","Capacity Management","Seamless Integration"],

};

function SetFieldValues(cStrategy)

{

this.getField("Dropdown2").setItems(Strategy[cStrategy]);

}

Custom Keystroke Dropdown 4

if( event.willCommit )

{

if(event.value == "")

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

else

SetFieldValues(event.value);

}

TOPICS
Acrobat SDK and JavaScript , Windows

Views

262

Likes

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
Community Expert ,
Dec 06, 2018 Dec 06, 2018

Copy link to clipboard

Copied

All of your strings need to be in quotes, such as "Profitable growth", "Operational excellence", etc.

Likes

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 ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

Hello!  They are all in quotes.  I went through the entire script twice to make sure they all are.  Any other suggestions?

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

They are not all in quotes.

Likes

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 ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

myDropdown4Values = ["","Profitable growth", "Optimal outcomes", "Top talent", "Operational excellence"];

this.getField("Dropdown5").setItems(myDropdown4Values);

var Strategy = {

Profitable growth: ["","Diversification","Differentiation","Sales pipeline","Existing product innovation","New product innovation","Geographical expansion"],

Optimal outcomes: ["","Access","Quality","Risk Score Accuracy","Comprehensive Health","Utilization Management","Data Interfaces","Provider Collaboration","Individual Engagement","Stakeholder Satisfaction"],

Top talent: ["","Diversity and Inclusion","Culture and Infrastructure","Talent Management","Talent Recruitment","Talent Development","Thought Leadership","Learning and Growth"],

Operational excellence: ["","Go-to-Market Discipline","Security & Compliance","Cross-Functional Optimization","Data Analytics","Customer Service","Capacity Management","Seamless Integration"],

};

function SetFieldValues(cStrategy)

{

this.getField("Dropdown2").setItems(Strategy[cStrategy]);

}

Custom Keystroke Dropdown 4

if( event.willCommit )

{

if(event.value == "")

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

else

SetFieldValues(event.value);

}

Ayana Shy, MBA

[Personal contact info removed - Mod]

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

I can't see any quotes there:

Profitable growth:

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

Look closer.

Likes

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 ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

OK.  I added the quotes as suggested, and the 2nd box shows the 4 options for the 1st box.  Please help!

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

What is the name of the 2nd box?

Likes

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 ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

Dropdown5.  The 1st box is Dropdown4.

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

You set the items here:

this.getField("Dropdown5").setItems(myDropdown4Values);

Likes

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 ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

I have that line in the script but Dropdown5 still has the same options that Dropdown4 has.  The 2nd list doesn't change at all.

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

You doesn't change the 2nd list.

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

In the script, the "SetFieldValues()" function uses "Dropdown2". This needs to be changed to "Dropdown5"

And as Try67 pointed out. The first set line needs to be changed to:

this.getField("Dropdown4").setItems(myDropdown4Values);

Fixing these two items will fix your script. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

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 ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

Thank you for your help!!!

I made the changes, and the 2nd box still does not populate with the corresponding options.  The 2nd box gives me just the initial 4 options.

Likes

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 ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

Here's the current script:

myDropdown4Values = ["","Profitable growth", "Optimal outcomes", "Top talent", "Operational excellence"];

this.getField("Dropdown4").setItems(myDropdown4Values);

var Strategy = {

"Profitable growth": ["","Diversification","Differentiation","Sales pipeline","Existing product innovation","New product innovation","Geographical expansion"],

"Optimal outcomes": ["","Access","Quality","Risk Score Accuracy","Comprehensive Health","Utilization Management","Data Interfaces","Provider Collaboration","Individual Engagement","Stakeholder Satisfaction"],

"Top talent": ["","Diversity and Inclusion","Culture and Infrastructure","Talent Management","Talent Recruitment","Talent Development","Thought Leadership","Learning and Growth"],

"Operational excellence": ["","Go-to-Market Discipline","Security & Compliance","Cross-Functional Optimization","Data Analytics","Customer Service","Capacity Management","Seamless Integration"],

};

function SetFieldValues(cStrategy)

{

this.getField("Dropdown5").setItems(myDropdown4Values);

}

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

You use for Dropdown4 and Dropdown5 the same values.

Why does you remove .setItems(Strategy[cStrategy]); ?

Likes

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
Community Expert ,
Dec 07, 2018 Dec 07, 2018

Copy link to clipboard

Copied

The SetFielValues function needs to be this:

function SetFieldValues(cStrategy)

{

     this.getField("Dropdown5").setItems(Strategy[cStrategy]);

}

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

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 ,
Dec 10, 2018 Dec 10, 2018

Copy link to clipboard

Copied

Thank you all for your replies.  I added that line and it still does not work.  Any suggestions?

Likes

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
Community Expert ,
Dec 10, 2018 Dec 10, 2018

Copy link to clipboard

Copied

LATEST

Post your full code again.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

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