Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 13th, 2006, 04:09 PM
Authorized User
 
Join Date: Nov 2006
Location: St James, Manitoba, Canada.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default calculating grand total

I'm doing a school project and I'm trying to add up several text boxes, however some of them are blank and when I calculate them I get a NaN result. Here is my code:

qty1= parseFloat(document.form1.qty_prt.value)
qty2= parseFloat(document.form1.qty_mon.value)
qty3= parseFloat(document.form1.qty_comp.value)
sub_tot=parseFloat(document.form1.subt.value)
tax_tot=parseFloat(document.form1.tax.value)
grand_tot=parseFloat(document.form1.grandt.value)
qty_tot=eval(qty1+qty2+qty3)
alert("quantity is " + qty_tot)


  #2 (permalink)  
Old December 18th, 2006, 06:19 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii blkskullwork!!

You need to check whether the text box is empty or having not a valid number
.Possible solution is use validtion that no text boxes have empty /invalid number.
then Add those text boxes value

Hope this will help you


Cheers :)

vinod
  #3 (permalink)  
Old December 18th, 2006, 10:36 AM
Authorized User
 
Join Date: Nov 2006
Location: St James, Manitoba, Canada.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
PIVOT TABLE Grand Total ... pls help !!!! laky Access VBA 0 June 2nd, 2006 03:47 AM
PIVOT TABLE Grand Total ... pls help !!!! laky Access 0 June 2nd, 2006 02:15 AM
Calculating total form! require assistance Neeko Java Basics 1 May 4th, 2006 06:48 AM
Grand Total mateenmohd Access 6 April 8th, 2005 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.