I have a list with a drop down menu and each selection effects multiple variables. is there any way to refine it down? here is a snippet:
if (selectedLeft == 'item 1')
row1Vis = false;
if (selectedLeft == 'item 1')
leftCounter = false;
if (selectedLeft == 'item 1')
leftNA = true;
is it possible to have it something like, if (selectedLeft == 'item 1') row1Vis = false, leftCounter = false, leftNA = true;
so i don't have to write out if (selectedLeft == 'item 1') 3 times.
cheers
CodePudding user response:
You can use body (){...}
if (selectedLeft == 'item 1') {
row1Vis = false;
leftCounter = false;
leftNA = true;
}
More about if-and-else , switch-and-case on language-tour
CodePudding user response:
You can use the if
body for your variable and also use &&
, ||
if you want to use two or more conditions. &&
means AND
, ||
means OR
:
if(selectedLeft == 'item 1' && selectRight == 'item 2') {
row1Vis = false;
leftCounter = false;
leftNA = true;
}