Variables - Integer vs. Character

by Nathan Lyle <natlyle(at)nmu.edu>

 Date:  Sun, 11 Feb 2001 22:21:18 -0500
 To:  hwg-techniques(at)hwg.org
  todo: View Thread, Original
Okay, this has been a thorn in my side for a long time, but I've always
managed to come up with some kludge that kept me from having to actually
find the answer. Until now. <sigh> How do I stop Javascript from treating
an int like a character? I have the following code:

		totalCost = base;
		totalCost += document.forms[0].motherboard_cost.value;
		totalCost += document.forms[0].hard_drive_cost.value;
		totalCost += document.forms[0].windows_software_cost.value;
		totalCost += document.forms[0].monitor_speakers_cost.value;
		totalCost += document.forms[0].sdram_cost.value;
		totalCost += document.forms[0].software_suite_cost.value;
		document.forms[0].total.value = totalCost;

Instead of adding values, I get concatinated results. (10 + 10 = 1010
instead of 20.)

Any ideas? Please please please?

~Nathan Lyle   (The Tragic Comedian Poet)

Email:  natlyle(at)nmu.edu    or    jopling(at)geocities.com
Web: http://euclid.nmu.edu/~natlyle
Phone: 906-227-5736

"Where would Christianity be if Jesus got eight to fifteen years with time
off for good behavior?" - New York State Senator James Donovan, speaking in
support of capital punishment. Quoted in the liner notes of an album by
Jello Biafra & Mojo Nixon

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA