Copy link to clipboard
Copied
Dear all,
I have 3 combo boxes: box1, box2, box3. I would like when I select a value in box1 to have box2 with values according to box1 and then box3 have values according to box2. I have started to write the code below. I don’t know how to finalise it to make it works correctly.
CODE
//First you make the values for box1.
myBox1Values = ["","CAP","FOD","GOV","RET","RES","NOF","OTH"];
//Then you populate the values to box1.
{this.getField("box1").setItems(myBox1Values)};
// Then you define what has to be shown in box2 when value is selected
var DeptData = {CAP:["AGR"], FOD:["","BAK","BEV"]};
//Finally you set the values of box2 function
SetFieldValues(cDeptName) { this.getField("box2").setItems(DeptData[cDeptName]); }
// Then you define what has to be shown in box3 when value is selected
var DeptData = {AGR:["","CRO","ANI","FIS"]};
//Finally you set the values of box3 function
SetFieldValues(cDeptName) { this.getField("box3").setItems(DeptData[cDeptName]); }
Copy link to clipboard
Copied
It's hard helping you without seeing the full code...
If you're interested, I've developed a tool that allows you to easily set up such "cascading" drop-down fields using a spreadsheet that contains all the data. You can find it here: Custom-made Adobe Scripts: Acrobat -- Create Cascading Dropdowns
Copy link to clipboard
Copied
See Programming list and combo fields in Acrobat and LiveCycle forms - Part 1 of 2 by Thom Parker. This is not a beginners project.
Your steps do not include clearing the other combo box if there is an invalid option in the first combo box.
Copy link to clipboard
Copied
Thank you for your answers.
This is the full code. I want to be able to have cascading drop down list. try67 your solutions is what I am looking for, however I don't want to pay for it. I have already a part of the code, just need to finalise it. Any idea?
Copy link to clipboard
Copied
If this is the full code you have then you're missing a lot... Where's the definition of the SetFieldValues function?
Copy link to clipboard
Copied
Hi tyr67,
In box1, in Keystroke script I have:
if( event.willCommit )
{
if(event.value == "")
//if nothing is chosen in box1 then box2 will be cleared
this.getField("box2").clearItems();
else
SetFieldValues(event.value);
}
In box2, in Keystroke script I have:
if( event.willCommit )
{
if(event.value == "")
//if nothing is chosen in box2 then box3 will be cleared
this.getField("box3").clearItems();
else
SetFieldValues(event.value);
}
Copy link to clipboard
Copied
OK. And where is the definition of the SetFieldValues function?
Copy link to clipboard
Copied
Maybe it is what I am missing in my code...I am very new in coding on JS.
Copy link to clipboard
Copied
The code you're using came from this tutorial: https://acrobatusers.com/tutorials/change_another_field
You should read it carefully and follow the instructions in it if you want to get it working... I'm not sure it will work for you, though, as the situation you're describing is more complex than the one referred to in that tutorial.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now