Skip to main content
Participant
April 10, 2019
Question

Problem within a textbox changing color

  • April 10, 2019
  • 1 reply
  • 313 views

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?

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
April 10, 2019

Try this:

if(Number(sl.valueAsString)==0)