Skip to content

Instantly share code, notes, and snippets.

@Zillionx
Created September 22, 2015 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zillionx/de746816bbce0c4ac9c7 to your computer and use it in GitHub Desktop.
Save Zillionx/de746816bbce0c4ac9c7 to your computer and use it in GitHub Desktop.
Sum two fields
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Sum Form</title>
<script>
function startCalc(){
interval = setInterval("calc()",1);
}
function calc(){
one = document.SumForm.firstBox.value;
two = document.SumForm.secondBox.value;
document.SumForm.thirdBox.value = (one * 1) + (two * 1);
}
function stopCalc(){
clearInterval(interval);
}
</script>
</head>
<body>
<form name="SumForm">
<input type=text name="firstBox" value="" onFocus="startCalc();"
onBlur="stopCalc();"> + <input type=text name="secondBox" value="" onFocus="startCalc();"
onBlur="stopCalc();"> = <input type=text name="thirdBox">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment