Copy link to clipboard
Copied
Hi,
I have a javascript problem with the following code:
var sl = this.getField("Heuvel-0");
if (sl.value == "")
{event.target.fillColor=color.white;}
else
{if(sl.value==0)
{event.target.fillColor=color.green;
event.target.textColor=color.red;}
else
{if(sl.value>=-.4 && sl.value<=+.4)
{event.target.fillColor=color.yellow;
event.target.textColor=color.red;}
else
{event.target.fillColor=color.red;
event.target.TextColor=color.white;}
}
}
everything works except for the 0 value. The box doesnt change to green. When I change it to a 1 in the code and the box everything works fine. Why can't I use the 0?
Copy link to clipboard
Copied
Try this:
if(Number(sl.valueAsString)==0)