Skip to main content
stepheng54012748
Known Participant
January 6, 2018
Answered

If anyone can offer advice on how to write javascript to return a 0.......

  • January 6, 2018
  • 1 reply
  • 968 views

If anyone can offer advice on how to write javascript to return a 0 if a number is less than zero I would greatly appreciate it.  I can't seem to figure this out.  Here is the scenario: I'm trying to get field L144 to return a positive number or a zero.  I'm looking at field L26 to make this determination.  I was thinking something along the lines:

var theField = event.value ("L26");

var theValue = theField.value;

if (+theValue > 0) {

    event.value (L144").value = +theValue;

}

else {

     event.value ("L144").value = "0";  

  }

Thank you in advance for any help with this!

This topic has been closed for replies.
Correct answer Bernd Alheit

Here is the code I have currently.  I entered an example that should have returned a positive number and nothing was returned.  I then entered a number that should have been a negative number which returned a 0 but nothing was returned.

var theField = event.value ("L26");

var theValue = theField.value;

if (+theValue > 0) {

    event.value ("Ll44").value = +theValue;

}


This is wrong:

event.value ("Ll44").value =

this is correct:

event.value =

1 reply

Bernd Alheit
Community Expert
Community Expert
January 6, 2018

Use only event.value = ...

stepheng54012748
Known Participant
January 6, 2018

I appreciate your input.  I tried and still no success.  I'm really new at writing Javascript so i'm not in complete understanding how to write code.  I probably haven't written this correctly. 

try67
Community Expert
Community Expert
January 6, 2018

Post your new code, as well as any error messages you're seeing the JS Console.