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

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

Community Beginner ,
Jul 07, 2023 Jul 07, 2023

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.

 

TOPICS
General troubleshooting , How to , JavaScript , PDF forms
400
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 ,
Jul 07, 2023 Jul 07, 2023
LATEST

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

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

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 ,
Jul 07, 2023 Jul 07, 2023

Script looks ok. What is the issue exactly?

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 ,
Jul 07, 2023 Jul 07, 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?

 

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 ,
Jul 07, 2023 Jul 07, 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?

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 ,
Jul 07, 2023 Jul 07, 2023

A text field not within the drop-down menu. Text field Distance to LMC - L10 to be shown when MCO - L10 is visible. 

 

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 ,
Jul 07, 2023 Jul 07, 2023

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;

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 ,
Jul 07, 2023 Jul 07, 2023
LATEST

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

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

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