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

BlackBerry ListField Tutorial Part 2

Blackberry ListField with Clicked Row this time i create based on rtm4bb code. it used manager as TableRowManager to create the field for each row. first i create MenuListField.java

MySQL and Java Developer's Guide

Now we begin the second book and thats called MySQL and Java Developer's Guide. Book before this is quiet advance for beginner but still for beginner. And i notice that previous book had only 4 chapter. Ill read that book again. Okay Lets start. This book consist MySQL and Java plus Connector/J that connect Java to MySQL. This book is perfect for beginner but not beginner in programming. I think that this book is a hardcore book. Everything they wrote even if they use GUI Object like form and button they only use a "Notepad" or should i say "Text Editor". i really love this book. From this book you need to install three things to make the code in the book work. a. Install mySql b. Install Java SDK @ http://java.sun.com/j2se/1.4.1/download.html. c. Installing Connector/J @mysql.com version 3.0 thats from the book. I use this : jdk-1_5_0_11-nb-5_5-win-ml.exe notice the nb-5_5 that means itll install netbeans 5.5. netbean 5.5 is IDE for jdk 1.5. its devel...