Expand my Community achievements bar.

Getting display text of dropdown list with some tweaks (bound item values, etc)

Avatar

Level 2

This is sort of confusing, so bear with me. I had some drop-down lists on a form, but a co-worker decided that the arrows were ugly, so I looked online and found out a way to hide them by putting a text field over it, setting the dropdown list to invisible, and then having it take focus and become visible on entering the text field. This works just fine. On exiting the dropdown list, I revert visibility back to the text field so that it takes the value of the dropdown list. Now, if the dropdown list is NOT bound to values (i.e., a list of M and F is bound to 0 and 1), then this.resolveNode("$").rawValue returns the value of the field, and I set the text field's rawValue to that and it works. When I bind the dropdown list to 0/1/etc, now it returns just 0 or 1. How do I get the display text of the dropdown list instead?

Here's the code I'm using:

on entering the text field - hiding text field, making it so that the DDL is now targeted and can be chosen:

this.resolveNode("dropdownlist").presence = "visible";

this.resolveNode("$").presence = "invisible";

xfa.host.setFocus("dropdownlist");

on exiting the dropdown list - setting value of text field to the selected value of DDL:

this.resolveNode("textfield").presence = "visible";

this.resolveNode("$").presence = "invisible";

this.resolveNode("textfield").rawValue = this.resolveNode("$").rawValue;

Again, this works perfectly fine when the dropdown list has no bound values. I have tried .value, .text, xfa.event.newText (only works on change event, which I don't want), but I don't know how to get the display value of the dropdown list. Please advise, thanks!

2 Replies

Avatar

Level 2

Thank you, that did it!

Edit: Can't seem to figure out how to select his post as the right answer...