Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Adding values of two fields together


Message #1 by "Craig Flannigan" <ckf@k...> on Thu, 22 Mar 2001 09:55:12 -0000
This is a multi-part message in MIME format.



------=_NextPart_000_0024_01C0B2B6.2FDEDAA0

Content-Type: text/plain;

	charset="Windows-1252"

Content-Transfer-Encoding: 7bit





Hi.



I want to be able to have two text boxes on a web page, and to be able to

enter values into them, and have a third box show the result of them being

added.



I've not touched Java yet, so any simple explanations would be great.





Thanks in advance

Craig.






Message #2 by Gregory_Griffiths@c... on Thu, 22 Mar 2001 10:22:38 +0000
I think that you will need Javascript, what you want is quite simple 

and most Javascript sites / books will cover enough prinicples to get 

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields together









 

Hi.

 

I want to be able to have two text boxes on a web page, and to be able 

to enter values into them, and have a third box show the result of them 

being added.

 

I've not touched Java yet, so any simple explanations would be great.

 

 

Thanks in advance

Craig.













Message #3 by "Craig Flannigan" <ckf@k...> on Thu, 22 Mar 2001 10:37:47 -0000
Hi,



I've ordered a Java book, but this is one of those "was

needed yesterday" type projects!! So reading would probably

put me back a bit.







-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: 22 March 2001 10:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #4 by Gregory_Griffiths@c... on Thu, 22 Mar 2001 11:18:09 +0000
Its not JAVA you need it is JAVASCRIPT they are different. Try a 

Javascript Newsgroup like comp.lang.javascript or alt.www.webmaster or 

the P2P Javascript mailing list, which is where you are likely to find 

more help



> -----Original Message-----

> From: ckf@k... [mailto:ckf@k...]

> Sent: 22 March 2001 10:38

> To: asp_web_howto@p...

> Cc: ckf@k...

> Subject: [asp_web_howto] RE: Adding values of two fields together

> 

> 

> Hi,

> 

> I've ordered a Java book, but this is one of those "was

> needed yesterday" type projects!! So reading would probably

> put me back a bit.

> 

> 

> 

> -----Original Message-----

> From: Gregory_Griffiths@c...

> [mailto:Gregory_Griffiths@c...]

> Sent: 22 March 2001 10:23 AM

> To: ASP Web HowTo

> Subject: [asp_web_howto] RE: Adding values of two fields

> together

> 

> 

> I think that you will need Javascript, what you want is

> quite simple

> and most Javascript sites / books will cover enough

> prinicples to get

> oyu going. Take a look and get back to us if you need more.

> 

> -----Original Message-----

> From: ckf@k... [mailto:ckf@k...]

> Sent: 22 March 2001 09:55

> To: asp_web_howto@p...

> Cc: ckf@k...

> Subject: [asp_web_howto] Adding values of two fields

> together

> 

> 

> 

> 

> 

> Hi.

> 

> I want to be able to have two text boxes on a web page, and

> to be able

> to enter values into them, and have a third box show the

> result of them

> being added.

> 

> I've not touched Java yet, so any simple explanations would

> be great.

> 

> 

> Thanks in advance

> Craig.

> 

> 
Message #5 by "O'Hara, Elliott M" <EMOHARA@k...> on Thu, 22 Mar 2001 06:56:28 -0500
good god guys! Just help him out

<Script language="javascript">

function Addme(){

txt3.value=(parseInt(txt1.value))+ (parseInt(txt2.value))

}

</script>

<input type="text" id="txt1" language="javascript" onchange = "Addme()">

<input type="text" id="txt2" language="javascript" onchange = "Addme()"

<input type="text" id="txt3>



try that...

no error checking or anything, so if they put in anything besides a number

your gunna get a runtime, but that should getcha started





-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





I think that you will need Javascript, what you want is quite simple 

and most Javascript sites / books will cover enough prinicples to get 

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields together









 

Hi.

 

I want to be able to have two text boxes on a web page, and to be able 

to enter values into them, and have a third box show the result of them 

being added.

 

I've not touched Java yet, so any simple explanations would be great.

 

 

Thanks in advance

Craig.





Message #6 by "Tim Morford" <tmorf@c...> on Thu, 22 Mar 2001 06:43:57 -0500
im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.elements['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





I think that you will need Javascript, what you want is quite simple

and most Javascript sites / books will cover enough prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields together











Hi.



I want to be able to have two text boxes on a web page, and to be able

to enter values into them, and have a third box show the result of them

being added.



I've not touched Java yet, so any simple explanations would be great.





Thanks in advance

Craig.













Message #7 by "Tim Morford" <tmorf@c...> on Thu, 22 Mar 2001 06:46:50 -0500
sorry there was a type o it is still early here



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.elements['num2'].valu

e

-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





I think that you will need Javascript, what you want is quite simple

and most Javascript sites / books will cover enough prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields together











Hi.



I want to be able to have two text boxes on a web page, and to be able

to enter values into them, and have a third box show the result of them

being added.



I've not touched Java yet, so any simple explanations would be great.





Thanks in advance

Craig.







Message #8 by "Tim Morford" <tmorf@c...> on Thu, 22 Mar 2001 06:50:56 -0500
ok sorry one more time .. it is still early i forgot to conver the strings



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)

Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





I think that you will need Javascript, what you want is quite simple

and most Javascript sites / books will cover enough prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields together











Hi.



I want to be able to have two text boxes on a web page, and to be able

to enter values into them, and have a third box show the result of them

being added.



I've not touched Java yet, so any simple explanations would be great.





Thanks in advance

Craig.



Message #9 by "Craig Flannigan" <ckf@k...> on Thu, 22 Mar 2001 12:05:22 -0000
Thank you!





-----Original Message-----

From: O'Hara, Elliott M [mailto:EMOHARA@k...]

Sent: 22 March 2001 11:56 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





good god guys! Just help him out

<Script language="javascript">

function Addme(){

txt3.value=(parseInt(txt1.value))+ (parseInt(txt2.value))

}

</script>

<input type="text" id="txt1" language="javascript" onchange

= "Addme()">

<input type="text" id="txt2" language="javascript" onchange

= "Addme()"

<input type="text" id="txt3>



try that...

no error checking or anything, so if they put in anything

besides a number

your gunna get a runtime, but that should getcha started





-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #10 by "Craig Flannigan" <ckf@k...> on Thu, 22 Mar 2001 12:07:54 -0000
Thank you very much.



I'm good with VBScript, but Javascript - useless!



Much appreciated!







-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:47 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





sorry there was a type o it is still early here



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num2'].valu

e

-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.





Message #11 by "Craig Flannigan" <ckf@k...> on Thu, 22 Mar 2001 12:11:44 -0000
Still, you've solved it in 5 mins, when I could have been

reading a book on this for 5 days before I get it!!



Thank you for saving me vast amounts of time!





-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #12 by "O'Hara, Elliott M" <EMOHARA@k...> on Thu, 22 Mar 2001 07:15:26 -0500
hey... been in your shoes.

I learned it by nessesity (never needed to know how to spell).

If it's client side, use javascript... Just do it, its not as bad as it

looks.



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Thursday, March 22, 2001 7:08 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





Thank you very much.



I'm good with VBScript, but Javascript - useless!



Much appreciated!







-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:47 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





sorry there was a type o it is still early here



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num2'].valu

e

-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #13 by "Craig Flannigan" <ckf@k...> on Mon, 26 Mar 2001 12:32:07 +0100
Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.













Message #14 by "O'Hara, Elliott M" <EMOHARA@k...> on Mon, 26 Mar 2001 06:52:36 -0500
function add() {



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+parseInt(document.myform.el

ements['num1'].value)

}



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.







Message #15 by "Tim Morford" <tmorford@n...> on Mon, 26 Mar 2001 06:50:36 -0500
yes im sorry i forgot to convert the scring values



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



sorry just replace the



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e



with this line



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



the parseInt() is what you need sorry about that



Tim

-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.





Message #16 by "Craig Flannigan" <ckf@k...> on Mon, 26 Mar 2001 13:03:44 +0100
Is it easy to make it accept decimals?



I.E 1.995 + 2.669 for example, or will it always round down?





Thanks.





-----Original Message-----

From: Tim Morford [mailto:tmorford@n...]

Sent: 26 March 2001 12:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





yes im sorry i forgot to convert the scring values



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



sorry just replace the



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e



with this line



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



the parseInt() is what you need sorry about that



Tim

-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.





Message #17 by "Craig Flannigan" <ckf@k...> on Mon, 26 Mar 2001 13:00:56 +0100
Thanks Tim.







-----Original Message-----

From: Tim Morford [mailto:tmorford@n...]

Sent: 26 March 2001 12:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





yes im sorry i forgot to convert the scring values



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



sorry just replace the



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e



with this line



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



the parseInt() is what you need sorry about that



Tim

-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #18 by "Daniel O'Dorisio" <dodorisio@h...> on Mon, 26 Mar 2001 06:47:27 -0500
-------------------------------

: function add() {

:

: document.myform.elements['num3'].value 

:

parseInt(document.myform.elements['num1'].value)+parseInt(document.myform.el

: ements['num1'].value)

-------------------------------



i am not good at javascript by any means... but

wouldnt this add the value of 1 to the value of 1 instead of the val of 1 to

the val of 2??



just a ??



Daniel



-----Original Message-----

From: O'Hara, Elliott M [mailto:EMOHARA@k...]

Sent: Monday, March 26, 2001 6:53 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





function add() {



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+parseInt(document.myform.el

ements['num1'].value)

}



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #19 by "Tim Morford" <tmorford@n...> on Mon, 26 Mar 2001 07:07:10 -0500
i think you an use a parseFloat() inplace of the parseInt()



if that does not work ABS() works the same in VBSCRIPT as JAVASCRIPT



Tim



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 7:04 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





Is it easy to make it accept decimals?



I.E 1.995 + 2.669 for example, or will it always round down?





Thanks.





-----Original Message-----

From: Tim Morford [mailto:tmorford@n...]

Sent: 26 March 2001 12:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





yes im sorry i forgot to convert the scring values



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



sorry just replace the



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e



with this line



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



the parseInt() is what you need sorry about that



Tim

-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #20 by "Craig Flannigan" <ckf@k...> on Mon, 26 Mar 2001 13:14:31 +0100
Yes, this version didn't work.



I think it was just a typo on this one.



-----Original Message-----

From: Daniel O'Dorisio [mailto:dodorisio@h...]

Sent: 26 March 2001 12:47 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





-------------------------------

: function add() {

:

: document.myform.elements['num3'].value 

:

parseInt(document.myform.elements['num1'].value)+parseInt(do

cument.myform.el

: ements['num1'].value)

-------------------------------



i am not good at javascript by any means... but

wouldnt this add the value of 1 to the value of 1 instead of

the val of 1 to

the val of 2??



just a ??



Daniel



-----Original Message-----

From: O'Hara, Elliott M [mailto:EMOHARA@k...]

Sent: Monday, March 26, 2001 6:53 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





function add() {



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+parseInt(do

cument.myform.el

ements['num1'].value)

}



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #21 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 26 Mar 2001 13:19:57 +0100
use parseFloat instead of parseInt



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 1:04 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





Is it easy to make it accept decimals?



I.E 1.995 + 2.669 for example, or will it always round down?





Thanks.





-----Original Message-----

From: Tim Morford [mailto:tmorford@n...]

Sent: 26 March 2001 12:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





yes im sorry i forgot to convert the scring values



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



sorry just replace the



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e



with this line



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



the parseInt() is what you need sorry about that



Tim

-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #22 by "Craig Flannigan" <ckf@k...> on Mon, 26 Mar 2001 13:21:00 +0100
Thanks.







-----Original Message-----

From: Tim Morford [mailto:tmorford@n...]

Sent: 26 March 2001 01:07 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





i think you an use a parseFloat() inplace of the parseInt()



if that does not work ABS() works the same in VBSCRIPT as

JAVASCRIPT



Tim



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 7:04 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Is it easy to make it accept decimals?



I.E 1.995 + 2.669 for example, or will it always round down?





Thanks.





-----Original Message-----

From: Tim Morford [mailto:tmorford@n...]

Sent: 26 March 2001 12:51 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





yes im sorry i forgot to convert the scring values



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



sorry just replace the



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e



with this line



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+

parseInt(document.myform.elements['num2'].value)



the parseInt() is what you need sorry about that



Tim

-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.



Message #23 by "Daniel O'Dorisio" <dodorisio@h...> on Mon, 26 Mar 2001 07:57:26 -0500
thats what i thought... just wondering.



daniel



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 7:15 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields together





Yes, this version didn't work.



I think it was just a typo on this one.



-----Original Message-----

From: Daniel O'Dorisio [mailto:dodorisio@h...]

Sent: 26 March 2001 12:47 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





-------------------------------

: function add() {

:

: document.myform.elements['num3'].value 

:

parseInt(document.myform.elements['num1'].value)+parseInt(do

cument.myform.el

: ements['num1'].value)

-------------------------------



i am not good at javascript by any means... but

wouldnt this add the value of 1 to the value of 1 instead of

the val of 1 to

the val of 2??



just a ??



Daniel



-----Original Message-----

From: O'Hara, Elliott M [mailto:EMOHARA@k...]

Sent: Monday, March 26, 2001 6:53 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





function add() {



document.myform.elements['num3'].value 

parseInt(document.myform.elements['num1'].value)+parseInt(do

cument.myform.el

ements['num1'].value)

}



-----Original Message-----

From: Craig Flannigan [mailto:ckf@k...]

Sent: Monday, March 26, 2001 6:32 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





Looking at this code that was kindly written for me - it

doesn't seem to add the numbers.



If for example we add 10 and 15 together, I get 1015. Now in

VB, I know what to do to get around this, by converting the

numbers from text to numeric, but I'm araid I'm stuck with

Java Script.



Can anyone point me in the right direction?



Many thanks.



-----Original Message-----

From: Tim Morford [mailto:tmorf@c...]

Sent: 22 March 2001 11:44 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





im not a master javascripter but i hope this works for you



<script language="javascript">

function add() {



document.myform.elements['num3'].value 

document.myform.elements['num1'].value+document.myform.eleme

nts['num1'].valu

e

}

</script>



<form name=myform>

<input type=text name=num1 size=3 ID=num1>

<input type=text name=num2 size=3 ID=num2 onChange="add()">

<input type=text name=num3 size=3 ID=num3>



Tim



-----Original Message-----

From: Gregory_Griffiths@c...

[mailto:Gregory_Griffiths@c...]

Sent: Thursday, March 22, 2001 5:23 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Adding values of two fields

together





I think that you will need Javascript, what you want is

quite simple

and most Javascript sites / books will cover enough

prinicples to get

oyu going. Take a look and get back to us if you need more.



-----Original Message-----

From: ckf@k... [mailto:ckf@k...]

Sent: 22 March 2001 09:55

To: asp_web_howto@p...

Cc: ckf@k...

Subject: [asp_web_howto] Adding values of two fields

together











Hi.



I want to be able to have two text boxes on a web page, and

to be able

to enter values into them, and have a third box show the

result of them

being added.



I've not touched Java yet, so any simple explanations would

be great.





Thanks in advance

Craig.




  Return to Index