Need custom text option in dropdown that doesnt replicate in text field
Copy link to clipboard
Copied
I am working on a PDF form in Acrobat Pro that has a Author drop down box that autopopulates an ID number in a text box. Right now when I enter a custom name that isnt in the drop down it populates the same information in the text box (i.e. Author: Jane Doe | ID: Jane Doe). I am using ## event.value = this.getField("Author 1").value; ## to pull the ID number as the export value of each author currently, but it is not allowing for a custom author name and custom ID number. I need it to go like this Author: Jane Doe | ID: XXXX-XXX-XXXX. TIA
Copy link to clipboard
Copied
Where is this script? Is is on the text box or the dropbox?
what event? Calculation, validate, etc.?
What is the exact custom text that is entered into dropdown? Be explicit.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks for responding,
I have the ## event.value = this.getField("Author 1").value; ## entered into the ID text box custom calculaiton script area.
I need the ability for the authors to enter a co-authors name that is not in the dropdown and then have the ability to fill in the ID box with a custom text number. Right now when I enter a new author into the Author dropdown the ID box fills in with the authors name as well instead of being blank where it can be entered.
Copy link to clipboard
Copied
The calculation script overrides custom entry in the ID field because it runs every time any field on the form is changed. So, the first thing to do is remove the calculation script. The next thing to do is to add a custom validation script to the dropdown. The Validation script is only run when the field value is changed.
This script needs to detect when the entered data is a custom entry, and when it is a selection from the list, then it can determine whether or not the ID value needs to be updated from the dropdown or cleared for custom entry.
To do this the item value will need to be searched.
Enter this script into the Custom Validation Script on the DropDown.
Also, replace the "ORCID" text with the real name of the ID field on your PDF.
var oIDField = this.getField("ORCID");
var bFound = false;
for(var i=0;i<event.target.numItems;i++)
{
if(event.target.getItemAt(i,false) == event.value)
{// Field value is in list, set ID
oIDField.value = event.target.getItemAt(i,true);
oIDField.readonly = true;
bFound = true;
break;
}
}
if(!bFound){
// Field value is not in list, clear ID
oIDField.value = "";
oIDField.readonly = false;
}
Use the Acrobat JavaScript Reference early and often

