Skip to main content
Known Participant
May 5, 2022
Answered

I have my background change color when value is entered, but how do I add numerous value

  • May 5, 2022
  • 1 reply
  • 603 views

For example v==3 turns red.  I would like to turn red if 9, 15, 21, 25, 27, 29 is entered.   How do I go about doing this?  Do I have to do invidual lines or do I put && between values?

My code knowledge is about .01.. I just find what I'm looking for online and tweak it.

 

var v = Number(event.value);
if (v==1) {event.target.fillColor = color.green;}
else if (v==2) {event.target.fillColor = color.yellow;}
else if (v==3) {event.target.fillColor = color.red;}
else event.target.fillColor = color.white;

 

 

This topic has been closed for replies.
Correct answer Nesa Nurani

You can't use && that would mean that multiple values exist at the same time, instead use || (or)

(v==1 || v==9 || v==15...etc)

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
May 5, 2022

You can't use && that would mean that multiple values exist at the same time, instead use || (or)

(v==1 || v==9 || v==15...etc)

Known Participant
May 5, 2022

Thank you, much appreciated!