473,805 Members | 2,077 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
14 2810
On Apr 3, 7:57 pm, ap.sak...@gmail .com wrote:
On Apr 2, 7:27 pm, Michael White <m...@mickweb.c omwrote:
Not good...
Mick

Any specific reason why?
Open a CPU monitor. Open the page you referenced, then watch the CPU
usage climb when you put focus on one of the inputs.
Got better?
Search this group, there are hundreds of examples:

<URL:
http://groups.google.com.au/group/co...rch+this+group
>
--
Rob

Apr 3 '07 #11
ap*******@gmail .com wrote:
On Apr 2, 7:27 pm, Michael White <m...@mickweb.c omwrote:

> Not good...
Mick


Any specific reason why?
Got better?
function calc(f){
f.thirdBox.valu e = +firstBox.value + +secondBox.valu e;
}

<form name="autoSumFo rm" action="">
<input type=text name="firstBox" onchange="calc( this.form);">
<input type=text name="secondBox " onchange="calc( this.form);">
<input type=text name="thirdBox" readonly>
</form>

But any time a user input is required you need to sanitize the entry.

Mick

Apr 3 '07 #12
Lee
ap*******@gmail .com said:
>
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.java script 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) :)
Generally speaking, this newsgroup is a forum where people who are
interested in developing code in Javascript can share information.
It's not a place where somebody who has no interest in learning to
write code asks other people to do the work for them.
--

Apr 4 '07 #13
ap*******@gmail .com said the following on 4/3/2007 5:56 AM:
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.java script FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptT oolbox.com/bestpractices/

Why so much negative energy?
Because without it to counteract all the positive energy in the universe
the universe would collapse and it would be all my fault.

Seriously, after you read about 3,000 posts from Google Groups users who
don't even come close to even trying to write code and they are asking
for someone to write the code for free, it becomes hard (if not
impossible) to maintain a positive attitude about it.
Instead you could be more productive and type your code
that is better and more usefull than this one (that works just fine
btw) :)
I do type my code, one letter at the time. Why won't I type code to do
what you want? Because I have no use for it. If you are seriously
interested in knowing what is wrong with that code, or want to learn JS,
then by all means post back and I will explain it.

--
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 4 '07 #14
On Apr 4, 1:47 pm, Randy Webb <HikksNotAtH... @aol.comwrote:
ap.sak...@gmail .com said the following on 4/3/2007 5:56 AM:
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?

Because without it to counteract all the positive energy in the universe
the universe would collapse and it would be all my fault.

Seriously, after you read about 3,000 posts from Google Groups users who
don't even come close to even trying to write code and they are asking
for someone to write the code for free, it becomes hard (if not
impossible) to maintain a positive attitude about it.
Instead you could be more productive and type your code
that is better and more usefull than this one (that works just fine
btw) :)

I do type my code, one letter at the time. Why won't I type code to do
what you want? Because I have no use for it. If you are seriously
interested in knowing what is wrong with that code, or want to learn JS,
then by all means post back and I will explain it.

--
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/
I second Randy. It would be great if people actually doing some
research before asking a question. It's even best if later the person
who was asking question, return to share his findings/solutions.
That's how the community should work.

Regards,
Hardono Arifanto
-----------------------
http://sodeve.net

Apr 4 '07 #15

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

Similar topics

7
1525
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
3323
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
4694
by: Mark 123 | last post by:
Hi I have a form with the input fields: ProductName Quantity and output fields: ProductPrice
8
4262
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
2667
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
2566
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
10609
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
10360
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
10366
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9185
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7646
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
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4323
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
3845
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.