These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Capture Display Text of Drop Down Field

jrusling
Registered: Mar 5 2010
Posts: 4

Hi.
I am trying to capture the display text of a drop down field in which each display field has a different value. Actually I want to capture both values and place in a separate field.
 
So the drop down list consists of text/value and I'm trying to do this on the change event of the DD. I can get the value easy enough using:
 
textfield1.rawValue = this.boundItem(xfa.event.newText);
 
But I can't capture the displaytext. I know there is a getDisplayText option but in order for that to work you have to know the selectedIndex number which seemed easy enough but oddly that number is not available until/unless I change the value a second time wherein I get the previous selectedIndex number. Been racking my brain for several hours on this and not making any progress. Any help would be appreciated. Thanks.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How about xfa.event.newText?

You also might want to read both parts of this article, the bits on LiveCycle forms:
http://acrobatusers.com/tutorials/2007/js_list_combo_livecycle/

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How about xfa.event.newText?

You also might want to read both parts of this article, the bits on LiveCycle forms:
http://acrobatusers.com/tutorials/2007/js_list_combo_livecycle/

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jrusling
Registered: Mar 5 2010
Posts: 4
Hi, Thom. Thanks for your response. As you can see from my original post, I mention that I am using xfa.event.newText for part of the solution but that only get's the "value" of the selection and not the display text which is what I am after.

Also, I read the article you referenced and unfortunaly it does not speak about the issue I am chasing.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are only two parts to any list selection, the display text and the item value. On the "Change" event the "xfa.event.newText" property contains the display text.

To get a better handle on what's going on, place this code into the change event for a drop-down. In fact, try moving this code around to different events on the drop-down so you can see what values are available in different events.

Note, that if you do not provide specific values for the list items that "boundItem" will return the display name.

// Current values are the "pre-select" values
console.println("value: " + this.rawValue);
console.println("Idx:" + this.selectedIndex);

// These are the selection values
console.println("Change: " + xfa.event.change);
console.println("New: " + xfa.event.newText);
console.println("Full: " + xfa.event.fullText);
console.println("Bound: " + this.boundItem(xfa.event.newText));


Getting the index of the selected item on a change is challenging, the script has to look through all the entries.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok, I was doing testing on Acrobat 8. It turns out that in Acrobat X, if there is no item value, then the "boundItem" function returns the index.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script