It sounds like your values are being recognized as strings vs. expressions.
if they are strings the + sign will concatenate them. if they are
expressions then + will add the two together. cut and paste the following
scripts into a page and run them:
<script language="JavaScript">
fred="5"
george="6"
total=fred+george
alert(total)
</script>
<script language="JavaScript">
fred=5
george=6
total=fred+george
alert(total)
</script>
the first script returns 56 because 5 and 6 are recognized as strings. the
second will return 11 because they are recognized as expressions. i hope
this helps
regards,
dennis baldwin
-----Original Message-----
From: Hayes, David [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 28, 2001 1:34 PM
To: CF-Talk
Subject: RE: javascript add problem
++ is the increment operator.
-----Original Message-----
From: Craig Dudley [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 28, 2001 10:27 AM
To: CF-Talk
Subject: RE: javascript add problem
+ is for concatenating strings (spelling?)
++ will add them up i think.
-----Original Message-----
From: Bernd VanSkiver [mailto:[EMAIL PROTECTED]]
Sent: 28 March 2001 17:13
To: CF-Talk
Subject: OT: javascript add problem
Sorry about the OT question, but am stumped as to why this won't work.
Trying
to use JavaScript to add the numbers in form fields together, instead of
adding them, it is appending them to each other. Here is my code:
<script language="JavaScript">
function AddToBasket()
{
OrderBooks.TotalQty.value = 0
OrderBooks.TotalQty.value = eval(OrderBooks.SW.value +
OrderBooks.SP.value)
}
</script>
It is taking the value of OrderBooks.SP.value and apending it to
OrderBooks.SW.value instead of adding them. For example,
OrderBooks.SW.value
= 3 and OrderBooks.SP.value = 5, I am getting 35 instead of 8. Have tried
it
without the eval() in there and have set each form value equal to a
javascript
variable also with no change in results.
Bernd VanSkiver
[EMAIL PROTECTED]
ColdFusion Developer
ICQ #: 916324
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists