Disable text fields on drop down selection

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

158

Likes

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

Disable text fields on drop down selection

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

159

Likes

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
Jun 11, 2019 0
Adobe Community Professional ,
Jun 11, 2019

Copy link to clipboard

Copied

Please explain more.

Likes

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
Reply
Loading...
Jun 11, 2019 0
Explorer ,
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.

Likes

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
Reply
Loading...
Jun 11, 2019 0
Most Valuable Participant ,
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?

Likes

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
Reply
Loading...
Jun 11, 2019 0
Explorer ,
Jun 11, 2019

Copy link to clipboard

Copied

Yes

Likes

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
Reply
Loading...
Jun 11, 2019 0
Most Valuable Participant ,
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

Likes

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
Reply
Loading...
Jun 11, 2019 0
Most Valuable Participant ,
Jun 11, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jun 11, 2019 0
Explorer ,
Jun 12, 2019

Copy link to clipboard

Copied

You are the Best!

Likes

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
Reply
Loading...
Jun 12, 2019 0