[Javascript] Re: Updating a text box - calculations

Matthew Palmer mpalmer at hezmatt.org
Mon Feb 14 00:36:34 CST 2005


On Mon, Feb 14, 2005 at 04:51:50PM +1030, Tim Burgan wrote:
> I have my 5 text fields.. that dollar values are entered into, then a 
> 6th box that calculates the total of all 5 boxes, but the values are not 
> being ADDED together for the totals box, instead the code is 
> CONCATENATING. What have I done, I can't figure it out?

Oh, that's just JavaScript design stupidity.  First, design an implicitly
typed language, then ensure that the same operator does wildly different
things depending on what types it's passed.

You first need to convert your strings to numbers, and *then* add them
together.  A quick grovel through your manual will give you the answer -- I
wouldn't want to spoil all your fun for you.  <grin>

Or, if you're really not into treasure hunts today:

<rot13>
uggc://jjj.wninfpevcgre.arg/snd/pbaireg2.ugz
</rot13>

- Matt
Who is feeling cryptically helpful today
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050214/f7da0ad1/attachment.pgp>


More information about the Javascript mailing list