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

dropdown value

Community Beginner ,
Feb 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

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

Views

449

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

correct answers 1 Correct answer

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;

Votes

Translate

Translate
Community Expert ,
Feb 27, 2024 Feb 27, 2024

Copy link to clipboard

Copied

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;

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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;

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

Copy link to clipboard

Copied

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?

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

LATEST

Thank you for your prompt reply.

 

Yes, it works!

I missspelled...

 

Thank you so much again 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