cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript Addition

Former Member
0 Kudos

Hello Experts,

I'm trying to add a JavaScript code into one of my fields so that it always computes the sum of two other fields. My code is like so:

this.rawValue = TotalCWAdd.rawValue + TotalCWDel.rawValue;

However, instead of adding the values, it concatenates them like a string. What's weird though is when I use subtraction like so:

this.rawValue = TotalCWAdd.rawValue - TotalCWDel.rawValue;

It correctly computes the field. Am I missing something here?

Thanks in advance,

Alfonso

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Paul,

Use the expression as given below:

this.rawValue = (TotalCWAdd.rawValue + TotalCWDel.rawValue);

It will resolve the issue since without brackets it concatenates the value.

Hope this helps!!

Regards,

Arafat

Answers (1)

Answers (1)

Former Member
0 Kudos

Problem solved. I just used the parseFloat() method like so:

this.rawValue = parseFloat(TotalCWAdd.rawValue) + parseFloat(TotalCWDel.rawValue);

Cheers,

Alfonso