I have a webpage that allows insurance agents to enter a group of trucks for an insurance policy. I want to keep track of the number of power units (tractors or trucks), the number of trailers and the total insured value (the sum of all the units' values). So for power units, if the unit being entered is a tractor or a truck I have a variable, nPowerUnits, that increments like this


nPowerUnits=nPowerUnits+1;


That variable works fine, as does nTrailers. However if I do the same thing with the total insured value Javascript concatenates the values rather than adding them numerically. Thus,

nTIV=nTIV+document.getElementById('value'+i).value;

results in "0, 01000,0100020000" beginning with the original value of 0 and adding, first 1000, then 20000. The correct answer should be 21000. I have tried using the number() function, as in

var nValue=document.getElementById('value'+x).value;

nTIV=number(nTIV)+nValue;

number(nTIV)=number(nTIV)+number(nValue);

and so on but I get an 'object expected' error.
How can I add two variable values and get a number instead of a string?