Hi,
I am trying to dynamically populate a drop down list on a form based on a selection in another drop down list. I have read the help file "To dynamically populate a second field after populating the first" which goes through an example, however I cannot get this example to work for me.
I know that the best way to do it is to create an xml file and connect the form to this file. I am new to programming in xml but have had some experience in other forms. The code that I have (from the help page) looks like this;
<?xml version="1.0" encoding="UTF-8"?>
<MyData>
<country/>
<countries>
<item uiname="United States" token="US"/>
<item uiname="Vietnam" token="SRV"/>
</countries>
<state/>
<US>
<item>California</item>
<item>New York</item>
<item>Texas</item>
</US>
<SRV>
<item>An Giang</item>
<item>Bac Giang</item>
<item>Bac Kan</item>
</SRV>
</MyData>
I have then followed the instructions on the page, and am unable to populate either field on my form. Perhaps there is something wrong with my code? Or any other suggestions would be greatly appreciated!
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Are you merging the data file into the form? If you are using Preview you have to point to the data file where the data to be merged resides. This can be found in the File/Form Properties/Preview section. If you are not using preview then you will still have to get the data file. You can use the Forms/Manage Form Data/Import Data menu item in Acrobat or Reader.
If that does not help then email the form and that data file to LiveCycle8@gmail.com and I will have a look.
Paul
Views
Replies
Total Likes
Are you merging the data file into the form? If you are using Preview you have to point to the data file where the data to be merged resides. This can be found in the File/Form Properties/Preview section. If you are not using preview then you will still have to get the data file. You can use the Forms/Manage Form Data/Import Data menu item in Acrobat or Reader.
If that does not help then email the form and that data file to LiveCycle8@gmail.com and I will have a look.
Paul
Views
Replies
Total Likes
Ahhh,
Thats what I was missing. I have got it working now.
Thanks Paul!
Views
Replies
Total Likes
Hi Paul,
I have another question,
I would now like to populate a third drop down menu based on the selection in the second one, however my code is going wrong somewhere as now when I put in the first 2 drop down lists, nothing appears in the second one. ie, the first drop down list I link to countries, and the second to state, as I did with the previous file, but now, when I preview it, I can choose a country, but nothing comes up in state. When I set the first drop down box to countries, I have to specify that I want it to show the uiname, but I can't do that with the second one when I select state using the XML file below, nothing is shown. Where am I going wrong?
<MyData>
<Country/>
<countries>
<item uiname="United States" token="US"/>
<item uiname="Vietnam" token="SRV"/>
</countries>
<state/>
<US>
<item uiname="California" token="CA"/>
<item uiname="New York" token="NY"/>
<item uiname="Texas" token="TEX"/>
</US>
<SRV>
<item uiname="An Giang" token="AG"/>
<item uiname="Ban Giang" token="BG"/>
<item uiname="Bac Kan" token="BK"/>
</SRV>
<time/>
<CA>
<item>6</item>
<item>7</item>
</CA>
<NY>
<item>5</item>
<item>4</item>
</NY>
<TEX>
<item>3</item>
<item>8</item>
</TEX>
<AG>
<item>2</item>
</AG>
<BG>
<item>1</item>
</BG>
<BK>
<item>9</item>
</BK>
</MyData>
Thank you for your help!
Views
Replies
Total Likes
You may want to try adding the command xfa.layout.relayout() to the end of your script. This causes the form to refresh. Without seeing the form it is hard to say but refreshing the lists after you change them is always a good idea.
Paul
Views
Replies
Total Likes
Views
Likes
Replies