• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Edit multiple dropdown menus at the same time

New Here ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

Help!  

I've been furiously working on a fillable PDF using Acrobat DC and I have (literally) thousands of dropdown menus that I would like to edit simultaneously.  The problem is that the Javascript that I'm trying to edit will not allow me to choose the "Validate" tab if I select more than 1 dropdown to edit.

Is there a way to do this without having to individually select each dropdown menu validation tabs to edit?  

 

More specifically, I want edit all the dropdowns from this:

 

var f = event.target;
var fv = event.value;

if (fv == "4") {
f.fillColor = color.green;
}
else if (fv == "2") {
f.fillColor = color.yellow;
}
else if (fv == "1") {
f.fillColor = color.red;
}
else {
f.fillColor = color.white;
}

 

To this:

 

var f = event.target;
var fv = event.value;

if (fv == "4") {
f.fillColor = color.green;
}
else if (fv == "2") {
f.fillColor = color.yellow;
}
else if (fv == "1") {
f.fillColor = color.red;
}
else if (fv == "D") {
f.fillColor = color.blue;
}
else {
f.fillColor = color.white;
}

 

Thank you in advance!

 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

Yes,  Convert your "Validation" script into a string, and then use the "field.setAction()" function to set the script to all the dropdowns.

 

You'll find a helper tool here that converts scripts to strings (it's not free).

https://www.pdfscripting.com/public/JavaScript-to-Text-Converter.cfm

 

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 23, 2019 Dec 23, 2019

Copy link to clipboard

Copied

If you're using the same script for all fields then you should really put it in a doc-level function and then just call it from the field's event (which you can set using the method described by Thom Parker above).

That would make editing the code later on much, much easier, as you would only need to edit it in one place.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 24, 2019 Dec 24, 2019

Copy link to clipboard

Copied

Thank you, Thom and Try67.  I'm new to Adobe and I don't know a thing about scripts (or programming) except what I have researched and been able to put together.

If I purchase the subcription, will it be fairly straight forward or do I need some basic knowledge on how scripts work?

 

To put things in perspective: i don't know what  you or Thom are talking about:

1- Convert your "Validation" script into a string, and then use the "field.setAction()" function to set the script to all the dropdowns.

2- put it in a doc-level function and then just call it from the field's event (which you can set using the method described by Thom Parker above).

 

Does that matter or is the said tool subcription require basic computer skills that seem to elude me?

 

Thanks guys and happy holidays!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2019 Dec 24, 2019

Copy link to clipboard

Copied

LATEST

Try67 has a point, forget converting the code to a string. It's much easier to use a document level script, especially if any changes need to be made later. 

 

To be successful at doing the tasks you'll need to do to get this done, you'll need to learn a bit about scripting in Acrobat.  So getting a subscription to PDFScripting.com would be a big help. 

Here are the task you need to perform.

 

1. Convert your code into a function.

2. Place that function code into a Document Level Script

3. Create a script to loop though all the fields on the form and add a function call to each of the fields where it is needed. 

 

 

So for #1:

 

function SetDropdownColor()

{

var f = event.target;
var fv = event.value;

if (fv == "4") {
f.fillColor = color.green;
}
else if (fv == "2") {
f.fillColor = color.yellow;
}
else if (fv == "1") {
f.fillColor = color.red;
}
else if (fv == "D") {
f.fillColor = color.blue;
}
else {
f.fillColor = color.white;
}

}

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines