DESIGN OF MATHEMATICAL CALCULATOR IN SCROPT

by barkkathulla 2012-09-19 20:06:03

HOW TO CREATE MATHEMATICAL CALCULATOR IN JAVASCRIPT?
<HTML>
<HEAD>
<TITLE>CALCULATIONS</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--Begin
function a_plus_b(form){
a=eval(form.a.value)
b=eval(form.b.value)
c=a+b
form.ans.value=c
}
function a_minus_b(form){
a=eval(form.a.value)
b=eval(form.b.value)
c=a-b
form.ans.value=c
}
function a_times_b(form){
a=eval(form.a.value)
b=eval(form.b.value)
c=a*b
form.ans.value=c
}
function a_div_b(form){
a=eval(form.a.value)
b=eval(form.b.value)
c=a/b
form.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>
<BODY>
<CENTER>
<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=" * " 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=text size=4 value=3 name="b">
<input type=text value=0 name="ans" size=9>
</form>
</center>
</body>
</html>
1093
like
0
dislike
0
mail
flag

You must LOGIN to add comments