473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Adding the values in text boxes

I have a large form, that has text boxes of numbers in rows and
columns. I need to sum the values in the columns, and put the total at
the bottom of the column. But I also need to sum the values in each
row, and put the total at the end of the row.

What is the javascript to sum the values to a few text boxes, and how
would I write the script for these totals to run all at once?

Thanks.
Jul 20 '05 #1
1 2262
Frank wrote:
I have a large form, that has text boxes of numbers in rows and
columns. I need to sum the values in the columns, and put the total at
the bottom of the column. But I also need to sum the values in each
row, and put the total at the end of the row.

What is the javascript to sum the values to a few text boxes, and how
would I write the script for these totals to run all at once?

Thanks.


Hi Frank,

It is not complicated at all.
You must just give every field a clear name and use some basic javascript to
do the adding.

for example:
your fields have the following names:
row1col1 row1col2 row1col3 row1col4 row1total
row2col1 row2col2 row2col3 row2col4 row2total
row3col1 row3col2 row3col3 row3col4 row3total
totalcol1 totalcol2 totalcol3 totalcol4

<script type="text/javascript">
var numrows = 3;
var numcols = 4;

function dototalrows(){
for (var row=1; row=<numrows; row++) {
var totalrow = 0;
for (var col=1; col=<numcols; col++) {
totalrow += document.forms["yourformname"]["row"+row+"col"+col].value;
}
document.forms["yourformname"]["row"+row+"total"].value = totalrow;
}
}
</script>

do the same for cols.
(I didn't check my code, so forgive me any typos.)

Maybe add some errorchecking for invalid values.

Good luck!
reagrds,
Erwin Moller
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: crjunk | last post by:
I have 4 TextBoxes on my form that I'm trying to add together to get a grand total. Here is the code I'm using: <SCRIPT LANGUAGE="JavaScript"> <!-- Beginning of JavaScript - function...
7
by: Gertjan van Heijst | last post by:
Hi, I really hope someone can help me because I've already spend 2 days on this problem and I'm not getting anywhere. I think the problem is that I don't really understand how text boxes store...
13
by: Shannan Casteel via AccessMonster.com | last post by:
I set up two tables (one with the regular claim info and another with ClaimNumber, PartNumber, and QuantityReplaced). The ClaimNumber is an autonumber and the primary key in both tables. I made a...
1
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box...
4
by: David Plotts | last post by:
I'm a beginner with VB.net, only had one class in college on it. I can't seem to remember how to add text boxes up. I want to add the values in text boxes together, and put the value into a...
4
by: ballygowanboy | last post by:
i've put this code together. there's a variable "s" giving me some grief at the mo, i'm actualy supprised it half works. it's a simple shopping cart, you pick the quantitly of items, and it...
1
by: cluce | last post by:
I am trying to add only my selected values but its only adding the first selected value in my list repeatedly to the amount of selected items. can someone help me with this? for example, lets say...
1
by: cluce | last post by:
I am trying to add only my selected values but its only adding the first selected value in my list repeatedly to the amount of selected items. can someone help me with this? for example, lets say...
2
by: Canye | last post by:
I have a very long list of codes that i was advised to put in a module but don't know where to start from. Also i have a botton in my software that i what to use to be adding tabs when running my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.