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

Dropdown Options Resulting In Black Out Fields

Community Beginner ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

Hi I'm currently using Adobe Acrobat Pro.

I'm designing a PDF form with dropdown option field. Its contains 10 dropdown options. If a user selects 7 of the 10 option I need ["dropdown1", "dropdown2", "dropdown3",]; fields to be blacked out.

Can anyone please help me with a script?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

530

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

correct answers 1 Correct answer

Community Expert , Mar 25, 2019 Mar 25, 2019

Yes, remove that line. It's remnant from an earlier version that I left in accidentally.

Votes

Translate

Translate
Community Expert ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

You can use something like this as the custom validation script:

var fields = ["dropdown1", "dropdown2", "dropdown3"]

for (var i in fields) {

    var f = this.getField(fields);

    f.readonly = (event.value=="7");

}

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 Beginner ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

Thanks for getting back to me I tried the below script but there seems to be something wrong with it?

var fields = ["dropdown1", "dropdown2", "dropdown3"]

for (var i in fields) {

    var f = this.getField(fields);

    f.readonly = (event.value=="Ballygawley","Dungannon","Lurgan","Lurgan GIOS","Omagh-Cookstown Rd","Omagh-Drumquin Rd","Omagh-Gortrush Rd");

f.required = true;

f.fillColor = color.transparent;

f.readonly = false;

} else {

f.required = false;

f.fillColor = color.black;

f.readonly = true;

}

}

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 ,
Mar 22, 2019 Mar 22, 2019

Copy link to clipboard

Copied

Yeah, your condition is wrong. Use this instead:

var fields = ["dropdown1", "dropdown2", "dropdown3"]

var values = ["Ballygawley","Dungannon","Lurgan","Lurgan GIOS","Omagh-Cookstown Rd","Omagh-Drumquin Rd","Omagh-Gortrush Rd"];

for (var i in fields) {

    var f = this.getField(fields);

    if (values.indexOf(event.value)!=-1) {

        f.required = true;

        f.fillColor = color.transparent;

        f.readonly = false;

    } else {

        f.required = false;

        f.fillColor = color.black;

        f.readonly = true;

    }

}

Edit: code fixed

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 Beginner ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

Thank you for getting back to me. When I copy and paste the code it generates the below error message?

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 ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

The error is at (event.value==);

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 ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

Yes, remove that line. It's remnant from an earlier version that I left in accidentally.

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 Beginner ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

LATEST

Thank you so much guys Bernd Alheit and

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