Skip to main content
Known Participant
Jun 11, 2019 1:59 PM UTC
Answered

Disable text fields on drop down selection

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Jun 11, 2019 2:59 PM UTC

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

7 replies

Thom Parker
Community Expert
Community Expert
Jun 11, 2019 2:19 PM UTC

Please explain more.

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
Jun 11, 2019 2:22 PM UTC

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
try67
Community Expert
Community Expert
Jun 11, 2019 2:49 PM UTC

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