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

dropdown value

Community Beginner ,
Feb 27, 2024 Feb 27, 2024

I have dropdownA include 1~5, if you choose 1 from dropdown, i want entryfield1 to grayoout.
If i choose 2 from dropdown, I want entryfield2 to grayout.
How I can get with javascript? 

TOPICS
JavaScript
1.0K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 27, 2024 Feb 27, 2024

By greyout you want to set it to readonly?

As custom calculation script of that dropdown, use this:

this.getField("entryfield1").readonly = event.value == 1 ? true : false;
this.getField("entryfield2").readonly = event.value == 2 ? true : false;

View solution in original post

Translate
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 27, 2024 Feb 27, 2024

By greyout you want to set it to readonly?

As custom calculation script of that dropdown, use this:

this.getField("entryfield1").readonly = event.value == 1 ? true : false;
this.getField("entryfield2").readonly = event.value == 2 ? true : false;

Translate
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 27, 2024 Feb 27, 2024

Thank you, Nesa!

I want to set it to read-only.
Could you also tell me for following case?
If you choose no3, set read-only for entryfield1 and entryfield2.

Translate
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 28, 2024 Feb 28, 2024

Use this:

var e1 = this.getField("entryfield1");
var e2 = this.getField("entryfield2");

e1.readonly = event.value == 1 || event.value == 3;
e2.readonly = event.value == 2 || event.value == 3;
Translate
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 ,
Mar 04, 2024 Mar 04, 2024

Dear Nesa,

 

Thank you for your reply.

When I set this code to the Javascript editor of entryfield1, it tells me like below.

 

Syntax Error missing ; before the statement

 

Could you tell me how to solve this?

Translate
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 ,
Mar 04, 2024 Mar 04, 2024

I also wonder if should I set this code to dropdown javascript editor or entryfield1 script editor.

Translate
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 ,
Mar 04, 2024 Mar 04, 2024

In my first post, I wrote to use script as custom calculation script of that dropdown.

There are no syntax errors in script, make sure you copy/paste script correctly.

Translate
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 ,
Mar 04, 2024 Mar 04, 2024
LATEST

Thank you for your prompt reply.

 

Yes, it works!

I missspelled...

 

Thank you so much again for your help!

Translate
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