Skip to main content
Participating Frequently
October 3, 2017
Answered

I have created a javascript to turn a message on if greater than 0 or greater that 100. It does not work for the number 1 or the number 10.

  • October 3, 2017
  • 1 reply
  • 1082 views

Here a my javascript not sure if something is wrong.

if(event.value > "0")

{

this.getField("message.1").display=display.visible;

}else

{

this.getField("message.1").display=display.hidden;

}

if(event.value > "100")

{

this.getField("message.1").display=display.visible;

}else

{

this.getField("message.1").display=display.hidden;

}

if(event.value == "100")

{

this.getField("message.1").display=display.hidden;

}

This topic has been closed for replies.
Correct answer try67

If event.value is a number, then you can't compare it to a string (like "0"). If it's a string you can't use mathematical operators (like ">") on it.

In addition, your if-conditions overlap. You need to better define how you want it to work and construct the conditions based on that.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 3, 2017

If event.value is a number, then you can't compare it to a string (like "0"). If it's a string you can't use mathematical operators (like ">") on it.

In addition, your if-conditions overlap. You need to better define how you want it to work and construct the conditions based on that.

Participating Frequently
October 3, 2017

I am not sure what you mean. If the number is 2 it works but it won't work if the number is 1?

Thanks M