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

Set text field to combobox selection - NOT export value

Grika
Registered: Dec 9 2009
Posts: 35
Answered

This should be an easy one but everything I try in the Custom Format Script of the target text box sets said text box to the "Export Value" unless the selection doesn't have one, in which case I do get the actual visible selection.

My Product Information:
Acrobat Pro 9.2, Macintosh
Grika
Registered: Dec 9 2009
Posts: 35
Through a lot of futzing, I finally got something to work by making a Custom calculation script of the following in the target text field:
var f = this.getField("ComboBoxName");var a = f.currentValueIndices;event.value = f.getItemAt(a, false);

I still feel that this is more complicated than it should be and I would appreciate help in simplifying the code.

Now for the next problem; This only works for existing selections in the Combo Box. I want manually entered selections to also appear and am yet unsuccessful. I feel it might need something along the lines of f.getItemAt(-1) as manually entered selections in a Combo Box (that allows "custom text") is seen as the last item in the list and is assigned the Value Index of "-1". Again, any help would be great.
mmazal
Registered: Jul 20 2009
Posts: 27
Everything I've read says you're on the right track
mmazal
Registered: Jul 20 2009
Posts: 27
this small change seems to include custom entries

var f = this.getField("combo");
var a = f.currentValueIndices;

if (a == -1)
{
event.value = f.value
}
else
{
event.value = f.getItemAt(a, false);
}
Grika
Registered: Dec 9 2009
Posts: 35
Brilliant! That worked perfectly. Thank you.