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

Dropdown Options Resulting In Black Out Fields

Community Beginner ,
Mar 22, 2019 Mar 22, 2019

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
846
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

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.

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

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

}

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

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;

}

}

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

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

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

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

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

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

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

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

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

Thank you so much guys Bernd Alheit and

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