[Javascript] 1+1+1=111?

Peter Brunone peter at brunone.com
Wed Jun 27 13:13:22 CDT 2001


Thomas,

    The answer to your problems is the parseInt() function, e.g.

var total = parseInt(formname.field1name.value) + parseInt(formname.field2name.value);

    Form data is treated as strings unless you specify otherwise.

Cheers,

Peter
  ----- Original Message ----- 
  From: McCoy, Thomas 
  To: 'javascript at LaTech.edu' 
  Sent: Wednesday, June 27, 2001 1:04 PM
  Subject: [Javascript] 1+1+1=111?


  Hello all!


  I am trying to create a form that uses client-side Javascript to sum numerical data.

  The form has six blanks where numbers are entered.  The seventh box will display the mathematical total of the numbers entered in the six boxes.  So far, I can only get the 7th box to either add the html tags together (not what I want) or compile the numbers in the box (if the first six contain 1,2,3,4,5,6... I get 123456 in the Total box).  Any ideas, before I pull all my hair out?


  Sincerely,
  Thomas McCoy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010627/49a6d3f3/attachment.htm>


More information about the Javascript mailing list