JavaScript实例技巧精选(10)—计算器实例2

>>点击这里下载完整html源码<<

这是截图:

JavaScript实例技巧精选(10)—计算器实例2

利用Javascript和html实现的另一个计算器实例,核心代码如下:

<script language="JavaScript">
<!--
function equa1() {
        a = document.form1.aa.value;
        b = document.form1.ab.value;
        c = a-b;
        document.form1.total1.value = c
        }
function equa2() {
        a = document.form1.ba.value;
        b = document.form1.bb.value;
        c = (a1)+(b1);
        document.form1.total2.value = c
        }
function equa3() {
        a = document.form1.ca.value;
        b = document.form1.cb.value;
        c = a/b;
        document.form1.total3.value = c
        }
function equa4() {
        a = document.form1.da.value;
        b = document.form1.db.value;
        c = ab;
        document.form1.total4.value = c
        }
//-->

</script>
<form name="form1"><center>
<table border=1 cellpadding=1 cellspacing=1>
<tr>
<td><input type="text" size=5 name="aa"> - <input type="text" name="ab" size=5></td>
<td> =<input type="text" name="total1" size=5></td>
<td><input type="button" value="Calculate" onClick="equa1()"></td>
<tr>
<td><input type="text" size=5 name="ba"> + <input type="text" name="bb" size=5></td>
<td> =<input type="text" name="total2" size=5></td>
<td><input type="button" value="Calculate" onClick="equa2()"></td>
<tr>
<td><input type="text" size=5 name="ca"> / <input type="text" name="cb" size=5></td>
<td>=<input type="text" name="total3" size=5></td>
<td><input type="button" value="Calculate" onClick="equa3()"></td>
<tr>
<td><input type="text" size=5 name="da">  <input type="text" name="db" size=5></td>
<td> =<input type="text" name="total4" size=5></td>
<td><input type="button" value="Calculate" onClick="equa4()"></td>
<tr>
<td colspan=3 align=center>
<input type="reset" value="Reset"></td>
</table>
</form>
上一篇:Java两种方法实现循环报数


下一篇:Android开发中的PhoneGap基本使用