Thanks.I used parseFloat() to do that and it works.

>From: [EMAIL PROTECTED] (Duncan Harris)
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Re: Indexed Tag and JavaScript Problem
>Date: Thu, 14 Feb 2002 15:12 +0000 (GMT Standard Time)
>
>[EMAIL PROTECTED] (SUPRIYA MISRA) wrote:
>
> > Now I have another problem.
> > In JavaScirpt I have;
> >
> > var total=0.0;
> > var x;
> >
> > for loop
> > x=document.currentForm.elements["actHour["+loop+"].faHrsDay1"].value;
> > alert(x);
> > total=total+x;
> > alert(total);
> > end loop
> >
> > x gets the correct values like 1,2,3
> > but total=0.0 then 0.01, then 0.012 and so on.
> >
> > It is doing string concatenation instead of adding them.
>
>
>That is because x is a string and if either of the arguments of + is a 
>string
>it will do concatenation. You need to force x to be a number using one of:
>
>total = total + Number(x);
>
>or
>
>total = total + (x - 0);
>
>
>Duncan Harris
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>Hartford, Cheshire, U.K., Tel: 07968 060418
>Looking for STRUTS contract work in the U.K.
>
>--
>To unsubscribe, e-mail:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>
>




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to