Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

List Box Index Problem

Avatar

Level 4

I am running 8.2 and I am having a problem returning the index value of item(s) selected in a List Box on my form in Designer.

I have a List Box that is populated by at webservice and everything works fine.  I am able to display the selected name(s)s for the item(s) selected in the list box but I can't seem to get the index value.  Below is my Javascript code.

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

xfa.host.messageBox(a.item(0).value); //Display's selection only for verification.

Does anyone have any advice on how to do this?  I have tried selectedIndex and index instead of value and nothing has worked.

Thank you in advance.

John

1 Accepted Solution

Avatar

Correct answer by
Level 10

What event is your code running on ....I would recommend the exit event. I would use ListBox1.selectIndex. Note that the index is 0 based and it is not set until you Exit (by default). There is a small checkbox (on the Object palette where you set the values) that allows you to set when you want the commit  to happen. You can change it to Select if you need it as the user makes changes to the listbox. I woudl not use the technique that you are using where you query the DOM.

Paul

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

What event is your code running on ....I would recommend the exit event. I would use ListBox1.selectIndex. Note that the index is 0 based and it is not set until you Exit (by default). There is a small checkbox (on the Object palette where you set the values) that allows you to set when you want the commit  to happen. You can change it to Select if you need it as the user makes changes to the listbox. I woudl not use the technique that you are using where you query the DOM.

Paul

Avatar

Level 4

If you look for "Getting the current or previous value of a drop-down list" in the Adobe LiveCycle Designer Help you should be able to find the code you're looking for.


CurrentValue.rawValue = xfa.event.newText;

PreviousValue1.rawValue = DropDownList.rawValue;

PreviousValue2.rawValue = xfa.event.prevText;

If you are just looking for the current value then the .rawValue should return the bound value and selectedIndex should provide you with the index starting at 0 and -1 for no value selected.