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

Trying to write a switch case, Help please!

Community Beginner ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Hello Everyone,

 

I am trying to write a switch case that uses an if/then statement inside it but I keep getting a Syntax error. I would like certain fields to be outlined green if Joint is selected and they aren't blank, and red if Joint is selected but they are blank. Please let me know what I am doing wrong...

 

switch(event.value) {case "Joint":
{
if((this.getField("LNS").value !== "") && (this.getField("FNS").value !== ""))
this.getField("LNS").strokeColor=color.green;
this.getField("FNS").strokeColor=color.green;
else if((this.getField("LNS").value == "") && (this.getField("FNS").value == ""))
this.getField("LNS").strokeColor=color.red;
this.getField("FNS").strokeColor=color.red;
};
break;

case "Individual"||"IRA"||"Entity"||"Trust"||"Individual 401K"||"Direct Business 529":

this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;
break;


default:

this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;

break;

}

 

 

Thank You Kindly!

TOPICS
How to , JavaScript , PDF forms

Views

1.1K

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 ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Try this:

switch(event.value) {
case "Joint":
{
if((this.getField("LNS").value !== "") && (this.getField("FNS").value !== ""))
{
this.getField("LNS").strokeColor=color.green;
this.getField("FNS").strokeColor=color.green;
}
else if((this.getField("LNS").value == "") && (this.getField("FNS").value == ""))
{
this.getField("LNS").strokeColor=color.red;
this.getField("FNS").strokeColor=color.red;
}
};
break;

case "Individual":
case "IRA":
case "Entity":
case "Trust":
case "Individual 401K":
case"Direct Business 529":
this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;
break;

default:

this.getField("LNS").strokeColor=color.black;
this.getField("FNS").strokeColor=color.black;

break;

}

 

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 ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Thank you for your reply! Your changes eliminated the syntax error, but when I type something into the fields to test for not blank, the outline remains red, instead of changing to green.

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 ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Where does you use the script?

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 ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

In the Account Type Field where Joint may be selected.

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
LEGEND ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Yes, but each field has multiple actions. It's very important to say which action you choose, for example "mouse down" or "validate". Only one will work for any given script.

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 ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

I am using the script in the custom validation section

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 ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

LATEST

Change the selection and it will fires the script.

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