Expand my Community achievements bar.

addItem and boundItem

Avatar

Former Community Member
Hi!<br /><br />I have 3 comboboxes (dropdownboxes) which are dependent of each other. To solve this matter I need to use the addItem method and boundItem property.<br />On page 554 of Adobe's XML Form Object Model 2.2 Reference the addItem method is described in such way:<br /><i>addItem( STRING param1 [, STRING param2 ] )</i><br />The second parameter should be the index.<br /><br />I made my script somewhat like this:<br /><br />function getCity(nIndex, targetObject){<br />var myMatrix = new Array(new Array("London", "Newcastle", "Liverpool"),new Array("Paris", "Nice", "Marcheilles"));<br />var myList=myMatrix(nIndex);<br />for (i=0;i<myList.length;i++){<br /> targetObject.addItem(myList[i], i);<br /> }<br /> }<br /><br />It works just fine without the ", i" part inside the parenthesis of addItem. Could someone please help me out?<br /><br />best regards, <br />Håkon
3 Replies

Avatar

Former Community Member
Designer will not accept the second parameter in addItem when I try to assign the counter 'i' to it.



How should I write the addItem method so it will accept numbers as the second parameter?



Thanks,

Håkon

Avatar

Former Community Member
Hi again!<br /><br />I found it out myself. Since the second parameter had to be a string I converted the number of the counter to a string.<br /><br /><i><br />//Clear the existing values in the dropdownlist<br />DropDownList2.clearItems();<br />DropDownList2.rawValue ="";<br />//Add the new ones with an indexed boundItem <br />var myIndex = this.boundItem(xfa.event.change);<br />var cities = new Array(<br /> new Array("New Orleans", "NYC", "L.A."),<br /> new Array("Paris", "Lyon", "Marcheilles"), <br /> new Array("London", "Liverpool", "Newcastle", "Manchester"), <br /> new Array("Tokyo", "Kyoto", "Hiroshima"), <br /> new Array("Bremen", "Hannover", "Hamburg", "Berlin"));<br />for (i=0;i<cities[myIndex].length;i++){<br /> DropDownList2.addItem(cities[myIndex][i] , String(i));<br /> }<br /></i><br /><br />Thanks for your interests,<br />Håkon