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

Is there a quicker way to add validation script to multiple dropdown lists?

New Here ,
Jul 12, 2017 Jul 12, 2017

if (event.value=="VD") 

    event.target.fillColor = color.gray; 

else if (event.value=="OD") 

    event.target.fillColor = color.ltGray;  

else event.target.fillColor = color.transparent; 

TOPICS
Acrobat SDK and JavaScript , Windows
523
Translate
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 ,
Jul 12, 2017 Jul 12, 2017

Put the code in a doc-level function and then use a script to set the Validation action of the fields to call that function.

Translate
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 ,
Jul 12, 2017 Jul 12, 2017

Thanks!  I guess I need more than that. How do I "Put the code in a doc-level function and then use a script to set the Validation action of the fields to call that function."

Translate
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 ,
Jul 13, 2017 Jul 13, 2017

Do you want to apply this code to all drop-downs in your file, or just some?

Translate
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 ,
Jul 13, 2017 Jul 13, 2017

Well, just some I guess.  There are alot of drop downs.  There are 360 drop downs for this specific questions. Basically what I want it to do is this...

The room# is typed in, there are two options for the status, "VD" and "OD", and final is blank.

Lets say the room number is 400, I want the status to be VD.  When I choose VD the background will change to gray.  I also want the room number to change to gray as well.  If I choose OD it will change to ltGray.

Hopefully that makes sense.

Translate
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 ,
Jul 13, 2017 Jul 13, 2017
LATEST

Go to Tools - JavaScript - Document JavaScripts. Create a new item (you can call it "scripts"), and paste this code into it:

function validateDropdown() {

    if (event.value=="VD")

        event.target.fillColor = color.gray;

    else if (event.value=="OD")

        event.target.fillColor = color.ltGray;

    else event.target.fillColor = color.transparent;

}

Then execute this code from the JS Console (adjust the first line to contain the names of the fields you want to have this validation script):

var dropdowns = ["Status1", "Status2", "Status3"]; //etc.

for (var i in dropdowns) {

    this.getField(dropdowns).setAction("Validate", "validateDropdown();");

}

Translate
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