Skip to main content
Known Participant
June 11, 2019
Answered

Disable text fields on drop down selection

  • June 11, 2019
  • 1 reply
  • 1441 views

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?

This topic has been closed for replies.
Correct answer try67

Yes


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

1 reply

Thom Parker
Community Expert
Community Expert
June 11, 2019

Please explain more.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
June 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.

try67
Community Expert
Community Expert
June 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?