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

Disable text fields on drop down selection

Participant ,
Jun 11, 2019 Jun 11, 2019

Copy link to clipboard

Copied

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

Views

681

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

Votes

Translate

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

Copy link to clipboard

Copied

Please explain more.

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

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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?

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

Copy link to clipboard

Copied

Yes

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

LATEST

You are the Best!

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