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

Jul 12, 2017

Copy link to clipboard

Copied

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

Views

124

Likes

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

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

Jul 12, 2017

Copy link to clipboard

Copied

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

Views

125

Likes

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

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
Jul 12, 2017 0
Jul 12, 2017

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jul 12, 2017 0
Jul 13, 2017

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jul 13, 2017 0
Jul 13, 2017

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
Jul 13, 2017 0
try67 LATEST
Jul 13, 2017

Copy link to clipboard

Copied

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();");

}

Likes

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
Reply
Loading...
Jul 13, 2017 0