Simple calculation (adding) in javascript

A

ap.sakala

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. :)
 
E

Evertjan.

wrote on 02 apr 2007 in comp.lang.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. :)

onchange="..."

onkeyup="...."

etc.
 
I

Ian Collins

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

yourInputElement.onkeypress = yourOnkeypressFunction;

where yourOnkeypressFunction is a function that processes the event.
 
A

ap.sakala

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

yourInputElement.onkeypress = yourOnkeypressFunction;

where yourOnkeypressFunction is a function that processes the event.


Thanks but I would appreciate the exempel.

Does anyone knows of the script where this is working?
 
I

Ian Collins

*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.
 
A

ap.sakala

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.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.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) :)
 
L

Lee

(e-mail address removed) said:
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.


--
 
H

Hardono Arifanto

(e-mail address removed) said the following on 4/3/2007 5:56 AM:



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.


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.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top