Skip navigation
Currently Being Moderated

Zero if negative number

Jun 19, 2012 2:39 PM

I am trying to get a form to show a zero if the number subtracted results in a negative.

 

ie $100 - $200 = $0

 

Please help the scripting afflicted.

 
Replies
  • Currently Being Moderated
    Jun 19, 2012 3:42 PM   in reply to jeanette614

    Hi,

     

    The script in the calculate event of the numeric field would need an if/else statement. For example (using JavaScript):

     

    var nAns = NumericField1.rawValue - NumericField2.rawValue; 
    
    if (nAns >= 0) {
         this.rawValue = nAns; 
    }
    else {
         this.rawValue = 0; 
    }
    

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 7:24 AM   in reply to jeanette614

    ...I'll just have to turn those scraps into a book!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points