1 Reply Latest reply on Aug 21, 2006 6:10 AM by NSurveyor

    simple addition

    Caurj
      I have two input texts (a and b)
      and I want to make (a + b)
      but if I dont enter one of the values the result is "NaN"

      how can I fix it?


        • 1. Re: simple addition
          NSurveyor Level 2
          Are a and b the instance names of the TextFields? If so, using a+b doesn't really make sense. You probably wanted to use a.text and b.text. But even using a.text+b.text won't give you the numerical sum because both of those are strings. And when strings are added, they get concatenated, e.g. "123"+"12" = "12312". So, we need to first convert these two into Numbers. And we can do that using the Number function, so then we get: Number(a.text)+Number(b.text);