Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Nested Drop Down Menus

Avatar

Former Community Member
I am trying to create nested drop down menus with LiveCycle Designer 8.0. In order to streamline the form I am creating, it would make sense to have a drop down list with 5 options. The users selection on this first menu would then determine the options available in the second drop down menu. A simple example of this would be the first menu would have a list of countries, and then the second menu would show allow users to select only cities that are in the country the user selected in the first menu. Thanks so much in advance for your help.
15 Replies

Avatar

Former Community Member
There is a sample that does exactly that. It ships with the product, look in this location under the folder where you installed the deisigner:



\LiveCycle Designer ES\8.2\EN\Samples\Forms\Purchase Order\Dynamic Interactive\Forms



Look at the country in the shipping address, it will change the province/state dropdown dpending on which country you choose.

Avatar

Level 4
That would probably be the best approach for your situation if the list data is unlikely to change often.



For reference for anybody trying to solve this problem where you are likely to have to change the data frequently or need have different drop-down data on each form instance, there's a page in the Designer help system walking through the steps of doing this with a data connection. It should be the first result for the search term:



"populating second drop-down"



I only stumbled across this recently and found it very useful.

Avatar

Former Community Member
I am not trying to hijack this topic, but is there anything comparable for radio buttons, where two become enabled based upon another one being selected?



Thank you!

Avatar

Level 10
To Seth:

There's an example of what you want that ships with Designer:

C:\Program Files\Adobe\LiveCycle Designer ES\8.1\EN\Samples\Forms\Purchase Order\Dynamic Interactive\Forms\Purchase Order.pdf



To TK18:

You can use an if...else script to show a hidden subform that has the next set of radio buttons:



Use on the Change event of the first set of buttons:

if (this.rawValue == 1){

subform.radiobuttongroup.presence = "visible";

}

else{

subform.radiobuttongroup.presence = "hidden";

}



And I think you want to put a default value on the hidden field - on the initialize event:

this.presence = "hidden";

Avatar

Former Community Member
Jono,



I used your code and, whether I replace "radiobuttongroup" with the actual name for the group or not, I get the following error:



Script failed (language is formcalc; context is xfa[0].frmClientApplication[0].#subform[0].OrgStruct[0].Corp[0])

script=if(this.rawValue == 1){

subform.OrgStructCorp.presence = "visible";

}

else{

subform.OrgStructCorp.presence = "hidden";

}



Error: syntax error near token '{' on line 1, column 24.



I inserted the other statement as an initialize event as you indicated.



Do I need to wrap the second set of buttons in a subform? Whether I wrap it or not, I still get the same error.



Thank you for your help!

Avatar

Level 4
I don't think FormCalc supports that type of if else construct (although I'm not 100% as I always use Javascript in forms).



Try changing the drop down boxes on the script editor panel to Javascript and Client (these settings aren't global, so make sure you select the correct script first).

Avatar

Former Community Member
Thank you, Robert. I changed it to JavaScript, and I no longer get the error. However, the hidden form never shows, when I make my selection (viz., select the button).

Avatar

Level 4
Try popping a message box up on the first line of the script to double check what the raw value for the radio button group is... I believe that this may vary depending on what (if any) bindings are defined for the group:



> xfa.host.messageBox("rawValue:"+this.rawValue);

Avatar

Former Community Member
Sorry, but no difference: I get no popup and the buttons are still not showing up. Let me give you a little more info that may be relevant.



I'm trying to have the user select the legal structure for an organization. The options are corporation, sole proprietorship, partnership, or other. If corporation, the second set of buttons should allow the user to select public or private. This second set of buttons is placed within the first exclusionary group, after the first button, but, in the hierarchy, it is listed after the other one.



HTH, thanks.

Avatar

Former Community Member
Robert,



Anything else that you could do for me?



Thanks!

Avatar

Level 10
All I can think of is that you don't have the correct path to the subform...



Where you've got:

subform.OrgStructCorp.presence



You need to put in the correct data for "subform" - I just had it there as a placeholder.

Avatar

Former Community Member
The code works, you would need to set the form properties correctly. follow the instructions below

open the xdp in designer

Go To File|Form Properties

Preview Tab

Select Dynamic XML Form for the drop down field of "Preview Adobe XML Form As"

then do a preview and click on the radio button

Avatar

Former Community Member
Jono,



I missed it at first, but then I understood it and replaced subform with the actual name.



Dr. Wojadubowski,



I did have "show as static pdf," which I don't normally miss. I corrected this, and it now works . . . in a way.



Why in a way? Although the additional set of buttons now displays, they wont disappear when I select one of the other buttons.



The idea is that when the corporation button is selected, public or private show up. However, when subsequently one of the other buttons (sole proprietorship, partnership, or other) is selected (hey, anybody can make mistakes :-)), the sub-buttons should now disappear. Should I put additional code?



Thank you!

Avatar

Level 10
Yes, you have to tell it what you want to happen...



Here's some code I've been playing with, based on what is selected several fields are made visible or hidden - hope this helps!



if (this.rawValue == 1){

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q27").presence = "visible";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q28").presence = "hidden";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q29").presence = "hidden";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q30").presence = "hidden";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q31").presence = "hidden";

}

else{

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q27").presence = "hidden";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q28").presence = "visible";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q29").presence = "visible";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q30").presence = "visible";

xfa.resolveNode("form1.SubformMain.Sections.SectionC.Q31").presence = "visible";

}

Avatar

Former Community Member
Adding something like this



xfa.form.frmName.frmNamePg1.buttongroup.presence = "hidden";



to each one of the buttons where the added group of buttons shouldn't show up take care of the issue.



Thanks everyone for your support! You're awesome!