> 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.

JavaScript naturally looks at field values as strings - you have to convert
them to numbers first

OrderBooks.TotalQty.value = Number(OrderBooks.SW.value) +
Number(OrderBooks.SP.value);

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

Reply via email to