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
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
object/property of the Change event itself and possibly the list object’s
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 the
object. In the case of the Change event (which occurs when the list’s selection changes), the
property 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:
will 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.
Posted by Stefan Cameron on September 23rd, 2006
Filed under Events,Scripting
Both comments and pings are currently closed.