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?
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