Navigation Menu
Alphabetical Listing
Site Contents

Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner














Internet.com

IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Developer Channel

FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


Social Bookmark

General

This script will automatically total boxes in a form. Use it to keep a running total of quantites or prices in an order form.


  
+
=

Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: autoSum.js


CSS

Paste this code into your external CSS file or in the <style> section within the HEAD section of your HTML document.


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

25. From: moustafa
great scribt
11/13/2008 16:55:16

thanks alot
i was in need indeed for that scribt

23. From: mark
10/15/2008 03:16:09

how about sum of 3 form boxes?

24. From: Lee (Admin)
11/06/2008 11:56:45

Mark,

You would just need to add another variable to the calc() function (with a different name), and add it to the autoSumForm line. Then add another box in the form, using the same name you used in the calc() function.

18. From: jamadagni
05/25/2008 06:44:26

good..thx

15. From: Teri Mobley
Code "enhancement"
05/22/2008 13:38:28

I love this script! It was exactly what I needed. However I modified the script to accomodate 3 different sections of my form, with 10 boxes in each section and 10 separate totals. how can I share it with the forum and/or original author?

16. From: Lee (Admin)
06/26/2008 11:46:24

Thanks! You can submit it to me at our JavaScript submission page.

19. From: Tom Goldsmith
prevent tabbing into the result field
04/23/2008 01:52:55

I am wondering how you would prevent someone from tabbing into the result field and over wirtting the computed result.

I can see where I can apply this technique in a registration form, but I am not comfortable with it if the computation result may be over-ridden by the user.

Thank you.
Tom

20. From: Lee (Admin)
10/31/2008 14:19:40

You would add the "readonly" attribute to the input control, e.g.,

input class="right" readonly="readonly" type=text name="thirdBox"

21. From: kev
04/22/2008 10:25:01

I need it to keep the running total - this doesn't. How can I do that?

22. From: Lee (Admin)
11/06/2008 10:32:50

You can find a script for that here

next comments...

Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.