Getting a List’s New Selection

Have you ever struggled to figure-out what item from a list (list box or drop down list) a user had just selected in the list’s Change event? If so, it’s possible you were trying to use the

bc. rawValue

property in order to get at this information.

Unlike other objects such as exclusion groups, the _rawValue_ property of a list object doesn’t reflect the new selection until the selected value is committed to it (by the user tabbing or clicking away from the list). That means that if you’re trying to, say, make a certain field visible at the moment when a particular item in the list is selected, you can’t use the _rawValue_ property because it still contains the _old_ (previous selection) value.

Instead, you must use the

bc. xfa.event.newText

object/property of the Change event itself and possibly the list object’s

bc. boundItem

function in order to determine the _value_ associated with the new selection.


When scripting any XFA event, you always have access to properties (information) of that event via thebc. xfa.eventobject. In the case of the Change event (which occurs when the list’s selection changes), thebc. xfa.event.newTextproperty is of particular interest because it contains the _text_ portion of the item that was just selected in the list. It’s important to note that this is only the text portion because if your list contains items with values that differ from their text (you’ve associated both a text and value part to each item in the list), you’re probably even more interested in determine the value associated with the new text that was just selected in the list. Fortunately, that’s an easy problem to solve as well:bc. this.boundItem( xfa.event.newText ); // JavaScript$.boundItem( xfa.event.newText ) // FormCalcwill return the _value_ bound (associated) to the text from the list’s new selection.So there you have it: When handling a list object’s (list boxes or drop down lists) Change event, don’t rely on the _rawValue_ to get the new selection: Use _xfa.event.newText_ and _boundItem(text)_ instead.