How to make particular value in field Read Only from dropdown list ?

Community Beginner ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Hi,

I am having 2 Dropdown DP1 and DP2.

the values of DP1 is A,B,C and DP2 value is E,F,G

 

if i select the 'A' from DP1, in DP2 value shld be 'E' and the remaining values ('F' and 'G') should be greyed out automatically.

 

if i select the 'B' from DP1, in DP2 value shld be 'F' and the remaining values ('E' and 'G') should be greyed out automatically.

 

if i select the 'C' from DP1, in DP2 value shld be 'G' and the remaining values ('E' and 'F') should be greyed out automatically.

 

i know how to make the whole field read only, but here i am asking like the particular value in drop down alone should be read only not a whole drop down.

 

Could any one please help me on this.

TOPICS
JavaScript

Views

105

Likes

translate

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
Adobe Community Professional ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

You can't set readonly some entries of the dropdown. At validation of the dropdown you can reject selected entries.

Likes

translate

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
Most Valuable Participant ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

You can't grey out items in a drop-down. As mentioned, you can use a script to reject certain selections, but a much better option is to change the actual list of available items in the drop-down to just those values that you want the user to select from.

Likes

translate

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 Beginner ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

Could you please provide the script to reject certain selections of dropdown.

Likes

translate

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
Most Valuable Participant ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

As the custom validation script of the drop-down you can use something like this:

 

if (this.getField("DP1").valueAsString=="A" && (event.value=="F" || event.value=="G")) {
	app.alert("The selected value is not allowed.");
	event.rc = false;
}

Likes

translate

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
Engaged ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

Just use caclulation script in "DP2" field

if(this.getField("DP1").valueAsString == "A")

event.value = "D";

use 'else if' to add other combinations.

Even if you try select other values it won't change.

Likes

translate

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 Beginner ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

Thank you so much, for your help. I will try and let u know.

Likes

translate

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 Beginner ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

@Asim123 

event.value pointing to DP1 aor DP2?

Likes

translate

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
Engaged ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

It points to DP2 field,

if DP1 value is A DP2 value will be D.

Likes

translate

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 Beginner ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

@Asim123 

You mentioned like "Just use caclulation script in "DP2" field"

Could you pls provide me the script, i m new to this adobe script.

Likes

translate

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
Engaged ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

I gave you script for A value now just write 'else'  (whitout quotes) and paste my script again and just change values form A to B and D to E and repeat again for last combination.

Likes

translate

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 Beginner ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

var field_dp2=this.getField('dropdown2');

var field_dp2=this.getField('dropdown3');

var fieldScript="switch (event.value) {

   

case 'A': 

field_dp2="E";

field_dp3="H";

break;

 

case 'B':  

field_dp2="F";

field_dp3="I";

break;

 

case 'C': 

field_dp2="G";

field_dp3="J";

break;

 }

 

 

Will this script work for 3 drop downs?

Likes

translate

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 Beginner ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

Based on value of dropdown1, dropdown2 and dropdown3 value gets populated.

Likes

translate

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 Beginner ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

@Asim123 this script will work

Likes

translate

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 Beginner ,
Feb 25, 2021 Feb 25, 2021

Copy link to clipboard

Copied

Got the answer, thanks for your help.

Likes

translate

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