...

View Full Version : JS adding two variabes help!



mrjoe12
08-07-2008, 12:47 AM
I was just looking at this and wondered how you would go about this.

Here's my code -


str += text[8][lang]+"\n "+formatNumber(ganimet[0], color[22], color[21],5000000)+" "+
text[13][lang]+", "+formatNumber(ganimet[1], color[22], color[21],5000000)+
" "+text[14][lang]+" "+text[21][lang]+" "+formatNumber(ganimet[2], color[22], color[21],5000000)+
" "+text[15][lang]+

which generates the below -


He captured
11.219 metal, 7.363 crystal and 4.462 deuterium.

text[13],[14] and [15] being the crystal metal and deut text's,

so that means I want to add together the following variables that are highlighted below -


+formatNumber(ganimet[0], color[22], color[21],5000000)+
+formatNumber(ganimet[1], color[22], color[21],5000000)+
+formatNumber(ganimet[2], color[22], color[21],5000000)+

how would I add all of the above variables to create a new line that says -


Total Profit: 23.044

Any ideas?

rangana
08-07-2008, 05:09 AM
Try this modificaton:


str += text[8][lang]+"\n "+formatNumber(ganimet[0], color[22], color[21],5000000)+" "+
text[13][lang]+", "+formatNumber(ganimet[1], color[22], color[21],5000000)+
" "+text[14][lang]+" "+text[21][lang]+" "+formatNumber(ganimet[2], color[22], color[21],5000000)+
" "+text[15][lang]+'\nTotal Profit: '+((formatNumber(ganimet[0], color[22], color[21],5000000))+(formatNumber(ganimet[1], color[22], color[21],5000000))+(formatNumber(ganimet[2], color[22], color[21],5000000))



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum