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

function for visible and hidden fields

Participant ,
Sep 19, 2021 Sep 19, 2021

Hi
Please, can anyone help me to solve this function?
I have a drop down menu "A" where I can select 4 options:
1) empty 2) purchase 3) purchase + construction 4) purchase + renovation.
When in the "A" drop-down menu I select "purchase + construction", or select "purchase + renovation" I want two fields to be shown. The field named "B" and the field named "C".
In all other cases I want the "B" and "C" fields to remain hidden.
I tried this formula:
if (event.value == "PURCHASE + BUILD") {this.getField ("B"). display = display.visible;}
if (event.value! = "PURCHASE + BUILD") {this.getField ("B"). display = display.hidden;}
if (event.value == "PURCHASE + BUILD") {this.getField ("C"). display = display.visible;}
if (event.value! = "PURCHASE + BUILD") {this.getField ("C"). display = display.hidden;}
if (event.value == "PURCHASE + RENOVATION") {this.getField ("B"). display = display.visible;}
if (event.value! = "PURCHASE + RENOVATION") {this.getField ("B"). display = display.hidden;}
if (event.value == "PURCHASE + RENOVATION") {this.getField ("C"). display = display.visible;}
if (event.value! = "PURCHASE + RENOVATION") {this.getField ("C"). display = display.hidden;}

The function only works when I select "PURCHASE + RENOVATION". When I select the "PURCHASE + BUILD" option, nothing goes.

Is there anyone who can please help me to make this function work?

TOPICS
JavaScript
1.1K
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Sep 19, 2021 Sep 19, 2021

Use this as validation script:

if(event.value == "PURCHASE + BUILD" || event.value == "PURCHASE + RENOVATION"){
this.getField("B").display = display.visible;
this.getField("C").display = display.visible;}
else{
this.getField("B").display = display.hidden;
this.getField("C").display = display.hidden;}

In dropdown field properties->options tab, tick 'commit selected value immediately'.

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 ,
Sep 19, 2021 Sep 19, 2021

If you used space in dropdown to set 'empty' item, it is still a character so  use " " not "".

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
Participant ,
Sep 19, 2021 Sep 19, 2021

I changed the function like this, but the result doesn't change:
if (event.value == "PURCHASE + BUILD") {this.getField ("RENOVATION COST"). display = display.visible; this.getField ("RENOVATION COST_1"). display = display.visible} else {this. getField ("RENOVATION COST"). display = display.hidden; this.getField ("RENOVATION COST_1"). display = display.hidden;}
if (event.value == "PURCHASE + RENOVATION") {this.getField ("RENOVATION COST"). display = display.visible; this.getField ("RENOVATION COST_1"). display = display.visible} else {this. getField ("RENOVATION COST"). display = display.hidden; this.getField ("RENOVATION COST_1"). display = display.hidden;}

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
Participant ,
Sep 19, 2021 Sep 19, 2021

that's how it works:
if (event.value == "PURCHASE + CONSTRUCTION" || event.value == "PURCHASE + RENOVATION") {this.getField ("RENOVATION COST"). display = display.visible; this.getField ("RENOVATION COST_1" ) .display = display.visible} else {this.getField ("RENOVATION COST"). display = display.hidden; this.getField ("RENOVATION COST_1"). display = display.hidden;}

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 ,
Sep 19, 2021 Sep 19, 2021

Use this as validation script:

if(event.value == "PURCHASE + BUILD" || event.value == "PURCHASE + RENOVATION"){
this.getField("B").display = display.visible;
this.getField("C").display = display.visible;}
else{
this.getField("B").display = display.hidden;
this.getField("C").display = display.hidden;}

In dropdown field properties->options tab, tick 'commit selected value immediately'.

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
Participant ,
Sep 19, 2021 Sep 19, 2021

Thank you very much

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
Participant ,
Sep 19, 2021 Sep 19, 2021

hi
always from the "A" pull-down menu, if it is empty I want the "PRICE" and "PRICE_1" fields to be hidden.
If, on the other hand, I select any item in the "To" field, the fields must be visible.
I tried this feature, but it doesn't work
if (event.value! = "") {this.getField ("PRICE"). display = display.visible; this.getField ("PRICE_1"). display = display.visible;} else {this.getField ("PRICE"). display = display.hidden; this.getField ("PRICE_1"). display = display.hidden;}
Could you please tell me where I'm wrong?

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 ,
Sep 19, 2021 Sep 19, 2021

If you used space in dropdown to set 'empty' item, it is still a character so  use " " not "".

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
Participant ,
Sep 19, 2021 Sep 19, 2021
LATEST

OK I fixed the function. Now works. Thank you very much

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