Search code examples
javascriptpdfadobe

Scripting in Adobe - How to convert a field to another type


Specifically, what I am trying to do is to turn a combobox into a text field on blur and back to a combobox on focus. This would be my workaround for centering combobox text. I've tried:

this.getField("fieldName").type = text;

but that hasn't worked for me. Am I missing something? Couldn't find anything about this in the documentation. I've seen add-ons that can change field types, so what is the javascript for it?


Solution

  • You can't. The field type is read-only.

    You'll need to use two separate overlapping fields that show and hide each other. The other option is to just use a text field and run a script to show a popup menu on mouseup which also runs when you tab in. Users can select from the popup or type into the field.