Well, your script is obfuscated, so I'm not going to try to give you any details as to how to edit it. However, I can say that when adding values (strings really) like:
you will get:
10030
If this is the problem, you need to make them into numbers first, example:
Code:
var n1="100";
var n2="30";
alert(parseInt(n1)+parseInt(n2));
Now you get:
130
There are less processor intensive ways to turn a string of this type (one that contains only numeric characters) into a number in javascript, you could do:
Code:
var n1="100";
var n2="30";
alert((n1-0)+(n2-0));
and still get:
130
I mention this only if it is workable in your code. If it is, it is better, if not, use the parseInt() method.
Also, if you are dealing with decimal points, you will need to use the parseFloat() method, or figure out a way to first get the decimal point out, do the math, and then put the decimal point back in the appropriate spot.
It is always best to avoid parseFloat if at all possible. It's results can sometimes be off by a minuscule amount. When that happens, you get a repeating decimal value like:
.299999999999999
instead of:
.30
Using parseFloat() is also the most resource intensive method of the three I've mentioned.
Bookmarks