2 Replies - 10410 Views - Last Post: 25 July 2006 - 05:19 AM

#1 kaushiks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 07-March 06

Addition through javascript

Post icon  Posted 24 July 2006 - 11:31 PM

hi,

I wanted to know how can we use arithmatic operations like addition, multiplication of two variables from two input boxes, and the answer will appear in the third input box.

actually u can say i have little or no idea of javascript and i have to implement this arithmatic opertaion in an application of mine, so can u guys plz help me with it.

one more i wanted to know whether the page gets refreshed when we perform this javascript operation.


regards,
kauhsik

Is This A Good Question/Topic? 0
  • +

Replies To: Addition through javascript

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Addition through javascript

Posted 25 July 2006 - 04:00 AM

Assuming a form named form1, and textboxes names text1, text2 and text3
var num1 = document.form1.text1.value;
var num2 = document.form1.text2.value;
document.form1.text3.value = parseFloat(num1) + parseFloat(num2);


Please note that there are several ways to accomplish this, and that the method above is not optimized in any way...it is meant to demonstrate the process in a manner which shows sequential steps for explanation purposes, not efficiency.

And no, the page will not be refreshed when performing a javascript operation unless you do so explicitly - javascript is client side code.
Was This Post Helpful? 0
  • +
  • -

#3 kaushiks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 07-March 06

Re: Addition through javascript

Posted 25 July 2006 - 05:19 AM

View PostAmadeus, on 25 Jul, 2006 - 02:52 AM, said:

Assuming a form named form1, and textboxes names text1, text2 and text3
var num1 = document.form1.text1.value;
var num2 = document.form1.text2.value;
document.form1.text3.value = parseFloat(num1) + parseFloat(num2);


Please note that there are several ways to accomplish this, and that the method above is not optimized in any way...it is meant to demonstrate the process in a manner which shows sequential steps for explanation purposes, not efficiency.

And no, the page will not be refreshed when performing a javascript operation unless you do so explicitly - javascript is client side code.


thanks a lot, will try it out what u have suggested.

regards,
kaushik
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1