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

nested drop down list

dlazenby
Registered: Aug 21 2010
Posts: 17

I would like to have a hierarchical drop down list. For example:
Shopping items:
1. Grocery
2. Department store
3. Automotive
4. Medical
User picks choice 4, medical: new list:
1. medications
2. health aids
3. misc. supplies
User picks choice 1, medications --> new list
1. antibiotics
2. pain medications
3. cardiac medications
User picks choice 2, pain medications --> new/final list:
1. Tylenol
2. Aspirin
3. Aleve
4. Morphine
5. Ibuprofen
When I searched the forums, for "nested drop-down list", the closest thing I found was a popup menu example/tutorial with javascript console by Thom Parker from Feb 12. 2009. It looks effective but complicated and laborious.
Is there anything out there simpler? I really only need to go 3 levels at most.
Thanks.

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

you can design a dropdown list as you said.
All you need is a set of form variables for your dropdown values and a little bit JavaScript.

I designed a sample for you.
There you find the form variables (Sel0, Sel1, Sel1_1, Sel1_2 ...), one drop down list and a reset button.
The Dropdown is populated with the variable "Sel0" at the beginning. If you select some value it is then populated with another form variable from a deeper hierachy.
All you need therefore is a switch:case JavaScript.

Check out this sample:
[url]https://acrobat.com/#d=JzdT3L5dIa3mr8YRNXMvuA[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

dlazenby
Registered: Aug 21 2010
Posts: 17
Radzmar,
Thanks for your response. I am truly impressed by how unselfishly you help out other users on a daily basis.
I looked at your example. It worked but it was not quite what I need. With your example to get to deeper levels, requires multiple mouse clicks for the user. Also with your example I wasn't sure where the "result" went to. (For example, with your nested drop down menu, if the user got to selection 1.1.2 I would want that selection to be visible in say a text field.
Upon further thinking, I am inclined to use the JS code that utilizes the app.popUpmenu code.
I copied some of the code from the how to section of Thom Parker's resource section on his WindJack Solutions web site ( http://www.windjack.com/resources/howto/WJHowTo_JS_PopupMenus.shtml), and from the example from the acrobatusers.com tutorial (http://acrobatusers.com/auc/content/tutorials/id_1392/PopupMenuExamples.pdf).
I then tried to work through this in LCD 8.2.1
I am able to get the menu to work/display but it doesn't output to the textfield adjacent to it.
Here is my simple example: for the display menu button:
topmostSubform.Page1.Button2::mouseUp - (JavaScript, client)
var aFruits = ["Fruits","Apples","Oranges"];
var aVeggies = ["Vegetables","Beans","Corn"];
var cRtn = app.popUpMenu(aFruits, aVeggies);
if(cRtn != null)
this.getField("Result2").value = cRtn;
Next to the display menu button is a text field named "Result2". This text field is just set to the usual defaults (value- user entered-optional; default binding-normal, binding name Result2.
Unfortunately, unlike his pdf example that works, I can't get it to work when I go to "preview pdf" in LCD.
I have tried every permutation and can't get it. Please advise. Thanks.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Thom's sample is written in Acrobat JavaScript, so it has to be modified for LCD.

You need to change this line, as the this.getField method is not supported in LCD.
this.getField("Result2").value = cRtn;
Change it into:
Result2.rawValue = cRtn;

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

dlazenby
Registered: Aug 21 2010
Posts: 17
That worked! Thanks.
It may be obvious, but I am a novice with the JavaScript. You wrote that the sample was in Acrobat JavaScript and has to be modified for LCD. That seems strange to me as I thought (erroneously obviously) LCD was like a superset of Acrobat Pro, with more of the functionality exposed for the "non-professional"/casual user.
At the bottom of your posts, you reference LCD ES Sripting Reference and LCD ES2 Scripting Reference. The ES reference is for v 8.1, ES2 for v 9. As I have asked about in another post LCD ES2 (v9) apparently is only available in an Enterprise version (megabucks, apparently not intended for the single-license Acrobat Pro user). I guess I should try to use the v8.1 reference. This reference as you know is fairly terse, tabular format and doesn't have much in the way of explanations.
The help file with LCD is woefully brief.
Do you have other informational sources that would be beneficial for me regarding JS with Acrobat and LCD. Perhaps a LCD JavaScript for dummies type reference/book/video tutorials. I am not even sure which flavor of JavaScript I should google to find this info.
Thanks again.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

LCD Documentations you generally need.

[url]http://help.adobe.com/en_US/livecycle/9.0/LiveCycle_Designer_Scripting_Basics.pdf[/url]
[url]http://help.adobe.com/en_US/livecycle/9.0/lcdesigner_scripting_reference.pdf[/url]
[url]http://help.adobe.com/en_US/livecycle/9.0/FormCalc.pdf[/url]
[url]http://help.adobe.com/en_US/livecycle/9.0/dynamic_assembly_guidelines.pdf[/url]
[url]http://help.adobe.com/en_US/livecycle/9.0/target_version_reference.pdf[/url]
[url]http://partners.adobe.com/public/developer/en/acrobat/sdk/AcroJS_DesignerJS.pdf[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

dlazenby
Registered: Aug 21 2010
Posts: 17
Thanks very much. I looked through all of those and they look very helpful. Of note, they are all for ES2 (v9.x) and obviously the current verstion of Acrobat Pro (9.3.4) comes with LCD ES (v8.2.1). In the target reference manual it seems to compare features in the various versions and there doesn't seem to be much more in v9. I would think there would be a lot of additional features going from ES1 to ES2.
Another question regarding the popupmenu app.:
1. Ultimately, I anticipate possibly 200-300 "choices" that the menu would branch to. Will the app bog down as a function of branching choices? (It would be approximately 10 1st order choices, and each of those would branch to 4-5 2nd order choices and finally branch to about 5-6 3rd order choices.)
2. With the popup up menu app the first order branch, branches to the right of the "display menu" button, the 2nd order branch goes to the left of the 1st order branch, and the 3rd order branch goes to the left of the 2nd order branch. This is only a minor annoyance, but is it possible to programmatically make them all branch to the right, like steps?
3. Finally, down the road I may have to substantially change all the choices? Is it possible to set it up so that it draws from a table or a spreadsheet or a database? I don't know if the app.PopupMenuEx method would lend itself to this.
All in all, I am very happy with what I have so far but I am trying to look into the future for problems, better solutions.
Thanks again.
adragton
Registered: Nov 14 2010
Posts: 3
radzmar

Maybe you can help with this. To expand to multiple DDL each dependant on the other, till the last one which fills in textfields.

my sample, but only one(1)DDL- need to expand.

located in EXIT-

//Initialize vars
var oUser = "";

//Get the User list into an object
var oTemp = xfa.datasets.data.Root.nodes;

//Loop through the nodes in the oTemp set
for (i=0; i< oTemp.length ; i++)
{
//set the currentElement to the 1st child node
currentElement = oTemp.item(i);
//Check to see if it is a user node
if (currentElement.name == "Row")
{
//It is a user node , assign the nodes to a new object
oUser = oTemp.item(i).nodes
// check to see if the value matches the one we chose in the DD
if (oUser.item(0).value == this.rawValue)
{
//we have a match
//Set the other fields with appropraite values
TextField1.rawValue = oUser.item(1).value;
TextField2.rawValue = oUser.item(2).value;
TextField3.rawValue = oUser.item(3).value;
}
}
}
jhclaudio
Registered: Jul 13 2011
Posts: 2
Hello all,
Can this script be accomplished in Acrobat X for Mac? If not what's a good solution.
Thanks in advance for your help.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Thom Parker has written a tutorial on this site that uses Acrobat and not LiveCycle Designer. Have you looked at that tutorial?

Also follow the links to the documentation for Acrobat JavaScript and JavaScript.

George Kaiser

jhclaudio
Registered: Jul 13 2011
Posts: 2
Thanks for the reply George. No, I haven't. I'll look for it.