Expand my Community achievements bar.

SOLVED

List Box Index Problem

Avatar

Former Community Member

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
Former Community Member

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
Former Community Member

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

Former Community Member

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.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----