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

Disable text fields on drop down selection

Participant ,
Jun 11, 2019 Jun 11, 2019

I have a drop down with 4 items. Actually this dropdown has a selection of business owners. Is this possible if we select 1 from drop down only one line is editable and if we do 2 then two lines editable?

The second case, is this possible when I choose 1 then only one field is displayed?

TOPICS
Acrobat SDK and JavaScript , Windows
1.2K
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 , Jun 11, 2019 Jun 11, 2019

You can use this code as the custom validation script of your drop-down field, then:

var prefixes = ["Name", "Perc", "Credit Score"];

var selectedValue = Number(event.value);

for (var i=1; i<=4; i++) {

    for (var j in prefixes) {

        this.getField(prefixes+i).display = (selectedValue>=i) ? display.visible : display.hidden;

    }

}

Make sure to tick the option to commit the selected value immediately, under the Options tab of the drop-down's Properties.

Edit: Small mistake in code fixed

Translate
Community Expert ,
Jun 11, 2019 Jun 11, 2019

Please explain more.

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

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
Participant ,
Jun 11, 2019 Jun 11, 2019

Number of Owners: Drop down with 1-4

Name, Perc, Credit Score (of each answer)

Number of Owners - Drop down with numbers 1-4. Once they pick the #, the exact number of Lines for their with a place for Percentage and a place for Credit score to be typed in

If not possible

only picked # of lines to be editable.

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 ,
Jun 11, 2019 Jun 11, 2019

So you have Name1, Name2, Name3, Name4, and the same for the other fields and you want to show/hide them based on the selection in the drop-down, basically?

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
Participant ,
Jun 11, 2019 Jun 11, 2019

Yes

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 ,
Jun 11, 2019 Jun 11, 2019

You can use this code as the custom validation script of your drop-down field, then:

var prefixes = ["Name", "Perc", "Credit Score"];

var selectedValue = Number(event.value);

for (var i=1; i<=4; i++) {

    for (var j in prefixes) {

        this.getField(prefixes+i).display = (selectedValue>=i) ? display.visible : display.hidden;

    }

}

Make sure to tick the option to commit the selected value immediately, under the Options tab of the drop-down's Properties.

Edit: Small mistake in 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 Expert ,
Jun 11, 2019 Jun 11, 2019

Sorry, there was a mistake in the code above. I fixed it now.

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
Participant ,
Jun 12, 2019 Jun 12, 2019
LATEST

You are the Best!

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