473,406 Members | 2,371 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,406 software developers and data experts.

Calculate while I type

Hello,
I believe that this has been answered somewhere but I cannot find it. I
have 51 textboxes on page. In 50 I can enter value. 51st should tell me
what is average of entered numbers.

As user types I want script to iterate trough form count and sum
non-empty fields and than divides this two numbers.I need to sum values
from fields that have value (not emty fields) and to divide this number
by number of non empty fields. This should occur on every change in any
of those 50 textboxes so to have live preview of average.

I'm really new to JS and I don't know even how to sum these numbers.

Thanks for response.

Jun 29 '06 #1
5 2206
wrote on 29 jun 2006 in comp.lang.javascript:
Hello,
I believe that this has been answered somewhere but I cannot find it. I
have 51 textboxes on page. In 50 I can enter value. 51st should tell me
what is average of entered numbers.

As user types I want script to iterate trough form count and sum
non-empty fields and than divides this two numbers.I need to sum values
from fields that have value (not emty fields) and to divide this number
by number of non empty fields. This should occur on every change in any
of those 50 textboxes so to have live preview of average.

I'm really new to JS and I don't know even how to sum these numbers.


Use
<input onkeyup='calculate()' ..
on each input.

Summing two numbers goes like ths:
result = n1 + n2

Sorry I am not going to write your code.
If you do not try, take a comercial programmer.
If you try, we are here to help some way.

Why use a textbox for output, that look kind of silly,
textboxes are for input.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 29 '06 #2
mi*********@gmail.com said the following on 6/29/2006 1:27 PM:
Hello,
I believe that this has been answered somewhere but I cannot find it.
Then you didn't look in the right places, or, it hasn't been answered
before but odds are it has been answered before.
I have 51 textboxes on page. In 50 I can enter value. 51st should tell me
what is average of entered numbers.
Easy enough.
As user types I want script to iterate trough form count and sum
non-empty fields and than divides this two numbers.
There is a better way to track that than looping through 50 form
elements every time one gets changed.
I need to sum values from fields that have value (not emty fields) and to
divide this number by number of non empty fields.
And if the value is not a number?
This should occur on every change in any of those 50 textboxes so to
have live preview of average.
OK. Average on the fly.
I'm really new to JS and I don't know even how to sum these numbers.


You could start with the group FAQ and the section that asks "Why does
1+1=11"?

<URL: http://jibbering.com/faq/#FAQ4_21>

Then, post your best effort and go from there.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 29 '06 #3
Thank you so much for your kind responses. I really don't expect that
anyone writes code for me, but I do expect than someone more
experienced can tell me the right direction.

Jul 3 '06 #4
wrote on 03 jul 2006 in comp.lang.javascript:
Thank you so much for your kind responses. I really don't expect that
anyone writes code for me, but I do expect than someone more
experienced can tell me the right direction.
Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 3 '06 #5
mi*********@gmail.com said the following on 7/3/2006 8:27 AM:
Thank you so much for your kind responses. I really don't expect that
anyone writes code for me, but I do expect than someone more
experienced can tell me the right direction.
I gave you that direction. You either didn't see it or chose to ignore it.

onchange="totalFieldReference.value += this.value"

That is as good a start as you will get. Test it, tinker with it, try to
reason it out.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 4 '06 #6

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

Similar topics

1
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a...
7
by: rick | last post by:
Can anyone help, I am try to create a simple form using a table, where a user can fill out quanty and price and have a total automatically calculated and inserted in another field. I stuck trying...
6
by: jochen scheire | last post by:
Is there a way I can calculate a field in a form based on another field in the same form. When clicking submit, both values should be posted to the next page. I want to be able to type in a value...
4
by: Jan Szymczuk | last post by:
I'm creating an MS Access 2000 database where I have a number of people entered using simple basic fields, Surname: SMITH Forenames: John DoB: 09/09/1958 Age:...
6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
4
by: Rich_C | last post by:
I'm sure this is very simple, but I have very little experience with javascript -- and what I do know isn't helping me here. I have a simple form where users can enter a quantity (qty) and cost...
5
chunk1978
by: chunk1978 | last post by:
hey... can anyone show me how to calculate sums to the 2nd decimal only? like: 5.50 + 4.00 = 9.50 i seriously have zero idea and could defo use some help...thanks! <script...
5
by: Michael | last post by:
Hi. I need dinamically calculate input text field based on parent static TD before showing content of input. Please, advice. Michael
3
by: coolguyraj | last post by:
I have a javascript code to take value from two text boxes and calculate on triggering the "OnBlur" function and display in the third box. The code works fine with one line item,If i have more...
9
by: Desyree | last post by:
I am putting together a database with the fields: 1. Number of Projects 2. Project (Name) 3. Project Contact 4. Company 5. Location (City, State) 6. Last Contact Date 7. Mw/g 8. Project Type
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.