Skip to main content
margauxm116749
Participant
July 23, 2017
Question

How to populate two other combo boxes according to value in first combo box?

  • July 23, 2017
  • 3 replies
  • 456 views

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]); }

This topic has been closed for replies.

3 replies

margauxm116749
Participant
July 23, 2017

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?

try67
Community Expert
Community Expert
July 23, 2017

If this is the full code you have then you're missing a lot... Where's the definition of the SetFieldValues function?

margauxm116749
Participant
July 23, 2017

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);

}

Inspiring
July 23, 2017

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.

try67
Community Expert
Community Expert
July 23, 2017

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