Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Dropdown - how to create dynamic lists

Avatar

Former Community Member
Hi experts,

I have the following problem and hope that one of you can help me:

I have a form to collect data of persons:











Engineer
Consultant


For each person (repeating form area based on the data), a drop-down box shall be present with the data of the node "roles". How can this be solved? My idea is to create the content of the drop down box using Java-Script in the "initialize" event:

- read the node "roles"
- loop over the "role"[i]
- write the value of role[i] into the drop down box

Here are my problems:
- how to read the "roles" and how to put the values into the dropdown
- what about the key - values? The value in the person.role node shall be "1" or "2" and not "Engineer".

Could you please provide me an idea and a code snipped I could use? Is there probably another easy way to solve this problem?

Thank you very much.

Thomas
3 Replies

Avatar

Former Community Member
Sorry, I made a mistake in the XML definition:<br /><br /> <br /><br />Topic<br /><br />Dropdown - how to create dynamic lists<br /><br />Thomas Mocker - 03:21am Apr 14, 2008 Pacific<br /><br />Hi experts,<br /><br />I have the following problem and hope that one of you can help me:<br /><br />I have a form to collect data of persons:<br /><persons><br /> < person ><br /> <name></name><br /> <role></role><br /> < /person ><br /> < person ><br /> <name></name><br /> <role></role><br /> < /person ><br /></persons><br /><roles><br /> <role id="1">Engineer</role><br /> <role id="2">Consultant</role><br /></roles>

Avatar

Former Community Member
Hi,<br />to reade data from the xml buffer you can use xfa.data object:<br />Suppose that your xml begins with <PEOPLE>, you will have xfa.data.PEOPLE.<br /><br />From that object you can access every node in the xml.<br />If you had a list, like ROLE node, you have to use <br />xfa.resolvenode('xfa.data.PEOPLE.roles.role[' + i + ']).value.<br />Remember that Javascrip can't understand the '[' char.<br />To add an item to a dropdownlist you have to use the addItem method.<br /><br />I hope this helps :-)<br /><br />Bye<br />Roberto Bellarmino

Avatar

Former Community Member
Hi Roberto,



sorry but I did not get you. Could you please provide ma a code snipped? Would be very great.



Take care.



Thomas