Multiple IF, AND, OR condition problem

Community Beginner ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

I have a form with several dropdowns. I'm trying to display FieldA if certain selections are made in two of the dropdowns. Here is custom calculation code for FieldA that works, but isn't quite what I need:

 

var c = this.getField("DropdownA").valueAsString;
var b = this.getField("DropdownB").valueAsString;


if ((c == "95" || c == "96" || c == "97") && (b !== "05"))
{
event.target.display = display.visible;
}


else {
event.target.display = display.hidden;
}

 

 

That gets me almost where I need to be, except that I need to add an 'OR' condition for var b as well. When I try to update the code with the OR condition like below, the field remains visible all the time:

 

 

var c = this.getField("3142CoverMaterial").valueAsString;
var b = this.getField("3142Base").valueAsString;

if ((c == "95" || c == "96" || c == "97") && (b !== "05" || b !== "16")) 
{
		event.target.display = display.visible;
    }


else {
    event.target.display = display.hidden;
	}

 

 

Any single var b condition will work, but as soon as I try to add an 'OR' to that side of the &&, FieldA remains visible if any of var c are true, regardless of var b.

My apologies for the clunkiness of my question, but can anyone shed any light about why this wouldn't work as I have it typed? Please let me know if clarification is needed. Thank you in advance.

 

TOPICS
JavaScript

Views

31

Likes

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

Adobe Community Professional , Jun 29, 2022 Jun 29, 2022

Use a 'AND' condition for var b.

if ((c == "95" || c == "96" || c == "97") && (b !== "05" && b !== "16")) 

Likes

Translate

Translate
Adobe Community Professional ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Use a 'AND' condition for var b.

if ((c == "95" || c == "96" || c == "97") && (b !== "05" && b !== "16")) 

Likes

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 ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

LATEST

So simple! Thank you @Bernd Alheit . This was the change I needed.

Likes

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