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);
}
Copy link to clipboard
Copied
All of your strings need to be in quotes, such as "Profitable growth", "Operational excellence", etc.
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?
Copy link to clipboard
Copied
They are not all in quotes.
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]
Copy link to clipboard
Copied
I can't see any quotes there:
Profitable growth:
Copy link to clipboard
Copied
Look closer.
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!
Copy link to clipboard
Copied
What is the name of the 2nd box?
Copy link to clipboard
Copied
Dropdown5. The 1st box is Dropdown4.
Copy link to clipboard
Copied
You set the items here:
this.getField("Dropdown5").setItems(myDropdown4Values);
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.
Copy link to clipboard
Copied
You doesn't change the 2nd list.
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.
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.
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);
}
Copy link to clipboard
Copied
You use for Dropdown4 and Dropdown5 the same values.
Why does you remove .setItems(Strategy[cStrategy]); ?
Copy link to clipboard
Copied
The SetFielValues function needs to be this:
function SetFieldValues(cStrategy)
{
this.getField("Dropdown5").setItems(Strategy[cStrategy]);
}
Copy link to clipboard
Copied
Thank you all for your replies. I added that line and it still does not work. Any suggestions?
Copy link to clipboard
Copied
Post your full code again.