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

Getting the value from a choice in combo box or custom text

StevenD
Registered: Oct 6 2006
Posts: 368
Answered

I got some code a while back from someone on a forum on how to get the value of choice made in a combo box. It works great but I think it only works with the value of a choice. I need to be able to use the value when a user enters custom text if one of the choices in the combo box list won't do. I don't know how to do this. Here is the code I have set up for a custom keystroke script of the combo box.

var myChoice = event.changeEx;

//Use willCommit to make sure the choice (export value)will stay in the text field and the item that has been chosen will show in the combobox field.

if(!event.willCommit)
{
if(myChoice == "Choose or enter a name.")
{
getField("Txt.VariableName").value = "";
}
else
{
getField("Txt.VariableName").value = myChoice;
}
}

And maybe there is a better way. Any ideas from someone out there?

StevenD

My Product Information:
Acrobat Pro Extended 9.1.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The "event.changeEx" value is only availible in the "uncommited" keystroke event. And it returns the export value, not the display value of the list item. This value is only useful for comboboxes that do not allow user entry.

The best way to use a combo box or any list control, is to set it to "Commit immediately on Selection". If it's setup for user entry then it's best to use the "commited" keystroke event. This way there's no confusion over user entry verses list selection. In the "commited" keystroke event, "event.value" will return the display value. regarless of whether or not it was selecected from the list or entered manually.

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]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

StevenD
Registered: Oct 6 2006
Posts: 368
Thanks.

StevenD