These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

An array to avoid lengthy switch/case statements?

SLDC
Registered: Oct 25 2010
Posts: 70

In a form I'm creating, the user chooses a code from a drop-down box. This populates another drop down box with the name of the appropriate person for that code. Each person handles multiple codes. Right now, I have an extended switch/case statement handling it, like this:
 
switch(this.RawValue) {
case "Code 1":
case "Code 2":
case "Code 3":
personNameField = "Joe Smith";
break;
 
case "Code 4":
case "Code 5":
personNameField = "Mary Quick";
break
 
------
 
I've been asked to add a second person-name field, but here, each individual code could have a different Person1 and Person2, so I can't have my nice lists of Code 1-Code 3, Code 4-Code 5. This causes a big problem when I'm dealing with several hundred codes. Instead of a run of 35 codes handled by Joe Smith, I'll need to have script handling each one of those 35, because the first is Joe Smith + John Doe, the next is Joe Smith + Frank Example, etc.
 
Is there some way to use an array to handle this? I think that it would be more efficient to have the first and second person fields look up their value from a table, but I don't know how that works in LiveCycle Designer.
 
Thanks,
SLDC

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Thom Parker has a tutorial about using a data object, Programming List and Combo fields in Acrobat and LiveCycle forms - Part 1. If you use spaces in an element name within the data object, then you need to place that element name within quotation marks.One could also use the value as an element name rather then the usual zero base numbering.

George Kaiser

SLDC
Registered: Oct 25 2010
Posts: 70
That's a great tutorial.

I take it that in order to use an array for this, I -must- have a data object attached to a subform? There's no way to simply put the array in, say, the Exit event of the first drop-down?

Also, I'm not filling the second and third drop-downs with multiple items, just with a single name each - so it's as though they were text fields, really.

I'm not really clear on how one compares a field's value to the first part of a series of subarrays, in order to pull out the second and third part of a particular subarray to populate those other fields.