Skip to main content
Participating Frequently
July 7, 2023
Answered

Help fixing a script to show multiple fields upon drop down selection

  • July 7, 2023
  • 1 reply
  • 485 views

I have 9 icon fields which are all hidden. I have three drop-down menus, each with three selections (Worth mentioning, each is set to Commit value immediately).

 

The code I have written is based on examples I have found in other threads regarding similar issues.

 

My code, which produces nothing, only connects itself to three fields and is as follows:

if (event.value == "12 O'Clock")
{
this.getField("MCO - L").display = display.visible;
this.getField("MCO - L10").display = display.hidden;
this.getField("MCO - L2").display = display.hidden;
}
else if (event.value == "10 O'Clock")
{
this.getField("MCO - L").display = display.hidden;
this.getField("MCO - L2").display = display.hidden;
this.getField("MCO - L10").display = display.visible;
}
else if (event.value == "2 O'Clock")
{
this.getField("MCO - L").display = display.hidden;
this.getField("MCO - L10").display = display.hidden;
this.getField("MCO - L2").display = display.visible;
}

 

What I want to achieve is a code that shows two fields and keeps the rest hidden. For example purposes, refer to them as Icon1 & Text1.

 

This topic has been closed for replies.
Correct answer try67

If "MCO - L10" field is visible, "LMC - L10" field should also be visible, else it should be hidden?

You can use this as calculate script of "LMC - L10" field:

event.target.display = this.getField("MCO - L10").display == display.visible ? display.visible : display.hidden;


You don't need the condition. This is sufficient:

event.target.display = this.getField("MCO - L10").display;

1 reply

Nesa Nurani
Community Expert
Community Expert
July 7, 2023

Script looks ok. What is the issue exactly?

Theo5E95Author
Participating Frequently
July 7, 2023

Apologies Nesa, it would seem the largest fault was that a suffix had been added to each icon [af_image].

My formula is correct, hussah! I need to have a text field become visible dependant on the selection made. How might I achieve this?

 

Nesa Nurani
Community Expert
Community Expert
July 7, 2023

Script should already do that.

What is the name of the field you wish to show/hide, and what are the choices in the dropdown?