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

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

842

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

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

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

Copy link to clipboard

Copied

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

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

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

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

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

Copy link to clipboard

Copied

@Asim123 

event.value pointing to DP1 aor DP2?

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

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

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

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

@Asim123 this script will work

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

Copy link to clipboard

Copied

LATEST

Got the answer, thanks for your help.

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