Expand my Community achievements bar.

Set values in ListBox with Javascript.

Avatar

Former Community Member
Hello.



I have a ListBox that can have multiple values (you can set this in Designer 7.1 by the way). I want to select 1, 2, x, values in this ListBox by script in Javascript. I can read these values like this:



var a = xfa.resolveNode ("ListBox1.value").nodes;

xfa.host.messageBox (a.item(0).value);



But how can I set the values?



Another question: Is it possible to get these values as an array or do I have to parse the value above to get the values?



/Per
2 Replies

Avatar

Former Community Member
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++){ DropDownList2.addItem(cities[myIndex][i] , String(i)); } <br />/Ulf DTP-tjänst

Avatar

Former Community Member
Hello.



Thanks but this was not what I wanted to do.

I have a listbox with some values. Let's say:

"Value 1" - "1"

"Value 2" - "2"

"Value 3" - "3"

You can now mark these by clicking and holding "Ctrl" down. I want to do the same but with a Javascript. For instance I want to click a button and that will give me "2" and "3" marked.



/Per