»
EnglishFrenchVietnamese

Print - 5 Function Calculator - JavaScriptBank.com

Full version: jsB@nk » Calculation » Calculator » 5 Function Calculator
URL: https://www.javascriptbank.com/5-function-calculator.html

5 Function Calculator © JavaScriptBank.comHere is a really simple JavaScript calculator code - with just 5 functions! (Add, subtract, multiply, divide, and power) This example can help you see how JavaScript evaluates math functions! Check it out.

Full version: jsB@nk » Calculation » Calculator » 5 Function Calculator
URL: https://www.javascriptbank.com/5-function-calculator.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">//AUHOR Rick Johnson<!-- Beginfunction a_plus_b(form) {a=eval(form.a.value)b=eval(form.b.value)c=a+bform.ans.value = c}function a_minus_b(form) {a=eval(form.a.value)b=eval(form.b.value)c=a-bform.ans.value=c}function a_times_b(form) {a=eval(form.a.value)b=eval(form.b.value)c=a*bform.ans.value=c}function a_div_b(form) {a=eval(form.a.value)b=eval(form.b.value)c=a/bform.ans.value = c}function a_pow_b(form) {a=eval(form.a.value)b=eval(form.b.value)c=Math.pow(a, b)form.ans.value = c}// End --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM name="formx"><input type=text size=4 value=12 name="a"> <input type="button" value="  +  " onClick="a_plus_b(this.form)">  <input type="button" value="  -  " onClick="a_minus_b(this.form)">  <input type="button" value="  x  " onClick="a_times_b(this.form)">  <input type="button" value="  /  " onClick="a_div_b(this.form)">  <input type="button" value="  ^  " onClick="a_pow_b(this.form)">  <input type="number" size=4 value=3 name="b"> = <input type "number" value=0 name="ans" size=9></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->