Skip to main content
Known Participant
February 5, 2025
Answered

Making batch changes to dropdown menu selection on multiple PDFs

  • February 5, 2025
  • 2 replies
  • 699 views

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!

Correct answer Thom Parker

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. 

 

2 replies

PDF Automation Station
Community Expert
Community Expert
February 5, 2025

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"}
}

}

 

 

 

Thom Parker
Community Expert
Community Expert
February 5, 2025

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. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
February 5, 2025

Good morning, Thom,

 

Yes! All the fields have the same name. 

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
February 5, 2025

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