Click to See Complete Forum and Search --> : ading value, stop concatenation


havey
07-08-2003, 01:42 PM
I'm pulling values from a url, hoping to add them as i write it to the page?
this is what i have:
<script>document.write(args["tot"]+args["reg"])</script>

it add 12 + 12 to give me 1212, would like an answer of 24 not 1212


thanks

Khalid Ali
07-08-2003, 01:44 PM
convert values first into integer values then add them

document.write(parseInt(args["tot"])+parseInt(args["reg"]))

Charles
07-08-2003, 01:45 PM
<script type="text/javascript">
<!--
alert(Number('12') + Number('12'))
// -->
</script>

havey
07-08-2003, 01:52 PM
Cheers Nature Boy!