Hello all.
I'm trying to make a form that has certain subforms appear depending on two choices made in the drop down menus. Looking through these forums and others I came up with what I thought would work...and it does for the most part. When I choose an option in the first drop down menu the second is populated as I want. When I choose an option in the second drop down menu the proper subforms are displayed below, but the first drop down menu loses its value.
I'm using switch (xfa.event.newText) for both drop down menus and I think that has something to do with it, but I cannot figure it out. The file is linked below. Any help would be greatly appreciated.
Also, the full version of this form could possibly have ~300 subforms by the time I'm finished with it. Is there a more efficient way to script this?
Thanks,
Mark
[url]https://share.acrobat.com/adc/document.do?docid=340cc02b-88e4-485b-9d03-fc9fd269099a[/url]
I changed your form a bit.
1. For populating drop down lists, it's more handy to use document variables (File > Form Properties > Variables).
A form variable can contain an array with all the values you need.
For the first drop down list "Choice1" you can add a form variable named "Choice_1" and this code for the array.
To populate the values to the drop down list you use a small script in the enter event of it.
Now every time you enter the drop down, it's populated with the values of the form variable "Choice_1".
2. For the second drop down list "Choice 2" you also can create form variables, one for every value of the 1st drop down list.
Form variable "Company_A":
Form variable "Company_B":
Form variable "Company_C":
To populate the values depending on the choice made on the 1st drop down list just put this script into the enter event of the 2nd drop down list.
3. To control your subforms visibility it's way better to control them by a script within the subforms itself.
Therefore you wrap all subforms that should dis/appear at once into one subform and then you place a script into the calculate event of this subform.
With this method you have a much better overview and not so extremely long switch-case-scripts.
https://share.acrobat.com/adc/document.do?docid=24c86a3f-6385-4ea2-8da4-c6d4b692eb9d
radzmar
• LoveCycle Blog
Documents you need:
• LiveCycle Designer ES2 Docs