Skip to main content

JavaScript Real Time Calculation


I've been around looking for javascript that can do Real Time Calculation.
javascript real time calculation, javascript real time calculation textbox.
by some lucky keywords i found this code. this is exactly the code that i want. it really do the real time calculation. and it doesn't need onChange or OnBlur function.
Just try it

Example


+

=
this is the javascript code
<script type='text/javascript' >
function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  one = document.autoSumForm.firstBox.value;
  two = document.autoSumForm.secondBox.value;
  document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
}
function stopCalc(){
  clearInterval(interval);
}
</script>
this is the html code

<form name="autoSumForm">
 
<input class="right" type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"><br>
+ <input class="right" type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"><br>
= <input class="right" type=text name="thirdBox">
</form>

thanks to this site javascript.internet.com . i finally found something useful. almost forgot its Created by: Jim Stiles | www.jdstiles.com

Comments

Unknown said…
Thanks a lot! Your tutorial is the best one I found - simple and works perfectly.
nav23 said…
CAN YOU PLEASE WRITE TIME DIFFERNCE CODE IN THIS SAME FORMAT CODE???
Unknown said…
Is there any other way to get answer like this? I tried with out success. Any way thanks for your help.
I learned a lot from Besant Technologies in my college days. They are the Best Java Training Institute in Chennai

Popular posts from this blog

iOS 5 Creating eCommerce with Shopping Cart App Part 1

[Created 11-28-2012] it seems like there are tons of tutorial ios and xcode for beginner out there. you can view the list at my post here http://javalearning-adventure.blogspot.com/2012/11/learning-xcode.html that's the link that i always update if i find anything. this tutorial will consist of step by step in creating Shopping Cart App. There will be Browse Product, Shopping Cart, and Checkout Method. I will update these later after i satisfied with the end result. These tutorial will also include web programming using php. but these php will only using basic sample not the very complex with mysql database and everything. these php pages will only creating json output. i think you don't need to learn php and json. you should only learn how to handle json using objective-c. I am still a beginner in xcode and objective-c, its still only 1 month since i started these tutorial. requirements suppose to be iOS 5 with xcode 4. [i will update these later][postponed...

BlackBerry ListField Tutorial Part 3

This Part 3 will consist of Networking, ListField, JSON and Thread. I'm really sorry for pending this part 3. I've been busy making money and still failed. Its just really hard to live in third world country by coding. anyway, There are few Library that you will need creating ListField with JSON data, but we wont touch that area first. we need to learn the basic. * note added : Aug 26 2013 The basic should be : Networking Thread ListField [if i find anything, will be add here]