473,796 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple calculation (adding) in javascript

Hello,

How the heck should I make this simple summering of a data without a
submit button?

Like in an excel sheet I would like to have a couple of cells in a
column and as soon the visitor types the number the sum should change,
regardless of how many raws there are and based on the setting
(adding, multiplying etc).

I would appreciate the code, link to the code or suggestions.

Thanks in advance. :)

Apr 1 '07 #1
14 2808
wrote on 02 apr 2007 in comp.lang.javas cript:
Hello,

How the heck should I make this simple summering of a data without a
submit button?

Like in an excel sheet I would like to have a couple of cells in a
column and as soon the visitor types the number the sum should change,
regardless of how many raws there are and based on the setting
(adding, multiplying etc).

I would appreciate the code, link to the code or suggestions.

Thanks in advance. :)
onchange="..."

onkeyup="...."

etc.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 1 '07 #2
ap*******@gmail .com wrote:
Hello,

How the heck should I make this simple summering of a data without a
submit button?

Like in an excel sheet I would like to have a couple of cells in a
column and as soon the visitor types the number the sum should change,
regardless of how many raws there are and based on the setting
(adding, multiplying etc).
You can use the (on)keypress event to capture the numbers the user
types. The easiest way is to simple write

yourInputElemen t.onkeypress = yourOnkeypressF unction;

where yourOnkeypressF unction is a function that processes the event.

--
Ian Collins.
Apr 1 '07 #3
On 2 Apr, 00:34, Ian Collins <ian-n...@hotmail.co mwrote:
ap.sak...@gmail .com wrote:
Hello,
How the heck should I make this simple summering of a data without a
submit button?
Like in an excel sheet I would like to have a couple of cells in a
column and as soon the visitor types the number the sum should change,
regardless of how many raws there are and based on the setting
(adding, multiplying etc).

You can use the (on)keypress event to capture the numbers the user
types. The easiest way is to simple write

yourInputElemen t.onkeypress = yourOnkeypressF unction;

where yourOnkeypressF unction is a function that processes the event.

--
Ian Collins.

Thanks but I would appreciate the exempel.

Does anyone knows of the script where this is working?

Apr 2 '07 #4
ap*******@gmail .com wrote:
On 2 Apr, 00:34, Ian Collins <ian-n...@hotmail.co mwrote:
>>ap.sak...@gma il.com wrote:
>>>Hello,
>>>How the heck should I make this simple summering of a data without a
submit button?
>>>Like in an excel sheet I would like to have a couple of cells in a
column and as soon the visitor types the number the sum should change,
regardless of how many raws there are and based on the setting
(adding, multiplying etc).

You can use the (on)keypress event to capture the numbers the user
types. The easiest way is to simple write

yourInputElem ent.onkeypress = yourOnkeypressF unction;

where yourOnkeypressF unction is a function that processes the event.
*Please* don't quote signatures.
>
Thanks but I would appreciate the exempel.
It's very easy to do, so I suggest you give it a try and learn, rather
than bodging something together from examples.

All you have to do is write a simple couple of line function to read the
value from input elements, add them and set the value of another. Bind
these to the element's onkeypress or onchange attributes and you are
done. A very good learning exercise, your textbook will show you how.

--
Ian Collins.
Apr 2 '07 #5
Thanks but I found this one instead of spending hours of learning
javascript:
http://javascript.internet.com/forms...orm-boxes.html


Apr 2 '07 #6
ap*******@gmail .com said the following on 4/2/2007 9:14 AM:
Thanks but I found this one instead of spending hours of learning
javascript:
http://javascript.internet.com/forms...orm-boxes.html
Does that site also explain how to quote on Usenet? And I would hate to
know I had to write that much bloated code to do what it does. But, you
got what you paid for.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 2 '07 #7
ap*******@gmail .com wrote:
Thanks but I found this one instead of spending hours of learning
javascript:
http://javascript.internet.com/forms...orm-boxes.html

Not good...
Mick

Apr 2 '07 #8
On Apr 2, 6:08 pm, Randy Webb <HikksNotAtH... @aol.comwrote:
>
Does that site also explain how to quote on Usenet? And I would hate to
know I had to write that much bloated code to do what it does. But, you
got what you paid for.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptT oolbox.com/bestpractices/
Why so much negative energy?

Instead you could be more productive and type your code
that is better and more usefull than this one (that works just fine
btw) :)

Apr 3 '07 #9
On Apr 2, 7:27 pm, Michael White <m...@mickweb.c omwrote:
>
Not good...
Mick
Any specific reason why?
Got better?
Apr 3 '07 #10

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

Similar topics

7
1523
by: mx2k | last post by:
Hello @ all, we have written a small program (code below) for our own in-developement rpg system, which is getting values for 4 RPG-Characters and doing some calculations with it. now we're trying hard to find out how to get it working with 'n' Characters, so you will be asked to enter a number at the beginning, asking you how many characters you want.
5
3322
by: Michael Hagstrom | last post by:
Good Day - I have written a form which collects input for a fare calculation. The form collects the following: 1) Departure or Destination Group (1,2,or 3) 2) Number of Adults 3) Number of Children aged 4 to 12 4) Number of Children under age 4
5
4692
by: Mark 123 | last post by:
Hi I have a form with the input fields: ProductName Quantity and output fields: ProductPrice
8
4253
by: rdavis7408 | last post by:
I am attempting what I would think would be a simple calculation of the cost of traveling a single mile. But I can not figure this out. The following is my script. Any help would be appreciated. I want the user to enter the price per gallon in one textbox, the miles per gallon in the next textbox and then press the button and get the cost per gallon by dividing the price per gallon by the miles per gallon.
10
2544
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 TeamScore(1-10) Employee3 TeamScore(1-10) Employee4 TeamScore(1-10) Then I submit this page with all the values in TeamScore for every employee and I want to perform a calculation based on the values in the drop-down and a
2
2195
cassbiz
by: cassbiz | last post by:
I may be in the wrong forum so Ronald don't shoot :) In my code I have an option box to choose a number - works fine. I want to carry over the new value to another field to do a recalculation. Primarily the field "$preis1" to change with the javascript. Here is the code. <script type="text/javascript">
28
2665
by: beach.dk | last post by:
Hi, I'm trying to implement a simple hash algorith called rs_hash in javascript, but I cannot get a correct result. In c the code looks like this:
2
1802
by: Uncle pablo | last post by:
I was searching ALL over for a javascript to just add up a column of numbers and I found this one here in an old question. It seemed to work great for my purposes EXCEPT it stops adding at four and I have more input fields than that. I tried adjusting the for (var i=1;i<=4;i++) { to for (var i=1;i<=12;i++) { to reflect the number of fields and thinking that was the issue but I got an error message about form elements being invalid. ...
12
2564
by: brossyg | last post by:
I have a very simple price times quantity calculation. The input is STWCORQuant: <input name="STWCORQuant" class="contactitalicbold" id="STWCORQuant" onChange="javascript:STWCORPrice();" value="0" size="8" style="text-align: right; font-family: ver"> And the fucntion is STWCORPrice(): <script language="javascript" type="text/javascript">
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9533
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10239
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7555
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4122
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.