Skip to main content
Participant
August 21, 2020
Question

Changing negative value to 0

  • August 21, 2020
  • 1 reply
  • 1661 views

Hello,

I know there are a number of posts about this but I still don't know what I'm doing wrong. FYI I am very new to Javascript, so I just need some actual help with the formula. What I need is when the result of an equation is negative, then the number turns to zero. 

For example, MLA is the text box I am using to calculate the formula. The simplified formula I had was (NA/12). However that number is often times negative. So I tried to do a javacript with an if statement and it just wasn't working. Can anyone help me with this? THANK YOU!

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
August 21, 2020

Hi, you can use something like this:

if(event.value < 0){
event.value = 0;
}

Participant
August 21, 2020

Thank you so much for your help! Okay sorry to sound totally ignorant but do I type is just like you have it there? I have tried to do something like that and it isn't working. Also I need to type in the calculation before so would I do:

(NA/12)

if(event.value<0)

{event.value=0;}

 

like that? and I put that in the customized formula table, correct? Thanks again!

Inspiring
August 21, 2020

You have any other fields? what exactly are you calculating?