on 05-18-2009 10:58 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Problem solved. I just used the parseFloat() method like so:
this.rawValue = parseFloat(TotalCWAdd.rawValue) + parseFloat(TotalCWDel.rawValue);
Cheers,
Alfonso
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.