Skip to main content
Known Participant
Feb 5, 2025 12:04 AM UTC
Answered

Making batch changes to dropdown menu selection on multiple PDFs

Hello!

 

Is it possible to make changes to multiple PDFs that have the same dropdown menu option?

 

I have a dropdown section that have the options YES or NO. For those PDFs that were previously selected with YES, I would want to change them all to NO and vice versa. Is it possible to do this without having to manually change each one?

 

Thank you!

Thom Parker
Thom ParkerCorrect answer
Community Expert
Feb 5, 2025 6:09 PM UTC

Well then, you can use a simpler version of the code provided by PAS.

 

var oFld = this.getField("DropdownName");

if(oFld.value == "YES")  oFld.value = "NO";

else oFld.value = "YES";

 

Add this code to an Acrobat Action Script. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often

5 replies

PDF Automation Station
Community Expert
Community Expert
Feb 5, 2025 1:39 AM UTC

Create an Action that excecutes the following Javascript

 

 

for(var i = 0; i< this.numFields; i++)
{
var fName = this.getNthFieldName(i);
var f=this.getField(fName);
if(f==null) continue;
if(f.type=="combobox")
{
if(f.value=="Yes"){f.value="No"}else
if(f.value=="YES"){f.value="NO"}else
if(f.value=="No"){f.value="Yes"}else
if(f.value=="NO"){f.value="YES"}
}

}

 

 

 

Translate
Thom Parker
Community Expert
Community Expert
Feb 5, 2025 12:42 AM UTC

Yes, this is possible. 

The issue is identifying the dropdowns. Do all the dropdowns in the all the different PDFs have the same name?  If not, is there a pattern to the names? 

 

The options in a dropdown field are set with the "field.setItems()" function.  Just call this function for fields that need changing. 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
Feb 5, 2025 4:39 PM UTC

Good morning, Thom,

 

Yes! All the fields have the same name. 

Translate
Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
Feb 5, 2025 6:09 PM UTC

Well then, you can use a simpler version of the code provided by PAS.

 

var oFld = this.getField("DropdownName");

if(oFld.value == "YES")  oFld.value = "NO";

else oFld.value = "YES";

 

Add this code to an Acrobat Action Script. 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often