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

Populate Combobox selection to a text field.

jbbirddog
Registered: Nov 4 2008
Posts: 6

I have combo box lists with values. I want to put the selection (not the value) in a textbox. I have only been able to get the value. What is the correct javascript to show the selection of the list, and not the export value?

My Product Information:
Acrobat Pro 8.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can easily get the list display value at the time the user makes the selection, using the "Change" event. The display value is in "xfa.event.newText".

At other times you have to do a little work to get the display value. Take a look at these two articles:

http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle/
http://www.acrobatusers.com/tutorials/2007/10/list_and_combo_in_lc/

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

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

jbbirddog
Registered: Nov 4 2008
Posts: 6
Thom

I apologize for my lack of understanding, but I do not understand the syntax of Adobe javascripts enough to understand how to use the information you sent me.

There is a copy of the form I'm using at:
http://facstaff.gpc.edu/~jjohnso4/pos.pdf

Any help you can give is greatly appreciated.

Don Johnson
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You should either set the "Export Value" for you option of instruction option to 0, zero. Without this value set the combo box value is the text string and not a number or test the value you are trying to apply to see if it is not a number is false by using the "isNaN()" method:

if(event.target.isBoxChecked(0) & isNaN(this.getField("AreaAMath").value) == false)
this.getField("HTA3").value = this.getField("AreaAMath").value;
else
this.getField("HTA3").value = 0;

I would make the "hours taken" field a calculation field and only fill in the hours when there is a number for the course and the "completed" check box is checked because a user could always go back and change an entry and using the check box action will not update for this change but a calculation will change.

George Kaiser

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I'm sorry, I assumed for some reason that you had a LiveCycle form. However, the articles I posted above are still valid.

During the Keystroke event both the display and export values are availible. The export value is in the "event.changeEx" property.

Place this in the keystroke event for the combobox
if(!event.willCommit)this.getField("AreaAMathR").value = event.changeEx;

Don't use the calcualte event. The calculate is fired any time any field changes, and you've got a lot of fields. Could slow things down a lot.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

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