Help with Javascript

B

bcap

I am trying to use 3 text fields to add up and the total compiles on a
forth.

For example:

Field 1: $5
Field 2: $5
Field 3: $10
Field 4: $20 (Field 1 + 2 + 3)

Also, is it posible to have field 4 update on the fly once field 1,2,
or 3 are clicked off?

Any thoughts/advise would be greatly appreciated!!!!


THANK YOU!
 
J

Joost Diepenmaat

bcap said:
I am trying to use 3 text fields to add up and the total compiles on a
forth.

For example:

Field 1: $5
Field 2: $5
Field 3: $10
Field 4: $20 (Field 1 + 2 + 3)

Also, is it posible to have field 4 update on the fly once field 1,2,
or 3 are clicked off?
Yes.

Any thoughts/advise would be greatly appreciated!!!!

See onblur, the value property and basic math.

I keep thinking you want to ask a question.

Joost.
 
W

William James

bcap said:
I am trying to use 3 text fields to add up and the total compiles on a
forth.

For example:

Field 1: $5
Field 2: $5
Field 3: $10
Field 4: $20 (Field 1 + 2 + 3)

C:\bin\jslibs\examples>js miniInteractiveConsole.js
Type "exit" to exit
js> [5,5,10].reduce( function(a,b) a+b)
20
js> eval( [5,5,10].join('+') )
20
 
D

David Mark

bcap said:
I am trying to use 3 text fields to add up and the total compiles on a
forth.
For example:
Field 1: $5
Field 2: $5
Field 3: $10
Field 4: $20 (Field 1 + 2 + 3)

C:\bin\jslibs\examples>js miniInteractiveConsole.js
Type "exit" to exit
js> [5,5,10].reduce( function(a,b) a+b)
20
js> eval( [5,5,10].join('+') )
20

Nice console dump, proving beyond a shadow of a doubt that 5 + 5 + 10
== 20.
 
T

Thomas 'PointedEars' Lahn

Conrad said:
C:\bin\jslibs\examples>js miniInteractiveConsole.js
Type "exit" to exit
js> [5,5,10].reduce( function(a,b) a+b) ^^^^^^^^^^^^^^^^^
20
js> eval( [5,5,10].join('+') )
20
Nice console dump, proving beyond a shadow of a doubt that 5 + 5 + 10
== 20.

...and that William is using a magic interpreter that won't throw a
syntax error for the first line.

That would have to be Mozilla.org SpiderMonkey 1.8 or later. The marked
part is an expression closure; the local version of the ECMAScript Support
Matrix already has it.


PointedEars
 

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

Forum statistics

Threads
474,129
Messages
2,570,770
Members
47,326
Latest member
Itfrontdesk

Latest Threads

Top