<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function _plus(form) {
x=eval(form.a.value);
y=eval(form.b.value);
retval=x+y;
form.ans.value = retval;
}
function _minus(form) {
x=eval(form.a.value);
y=eval(form.b.value);
retval=x-y;
form.ans.value=retval;
}
function a_multi_b(form) {
x=eval(form.a.value);
y=eval(form.b.value);
retval=x*y;
form.ans.value=retval;
}
function _div(form) {
x=eval(form.a.value);
y=eval(form.b.value);
retval=x/y;
form.ans.value = retval;
}
function _pow(form) {
x=eval(form.a.value);
y=eval(form.b.value);
retval=Math.pow(x, y);
form.ans.value = retval;
}
//-->
</SCRIPT>
<BODY>
<CENTER>
<FORM name="formx">
<table border=1 cellpadding=6>
<tr>
<td align=center bgcolor=blue>
<font color=yellow size=4><b>簡 易 計 算 機
</td>
</tr>
<tr>
<td align=center>
<input type=text size=4 value=12 name="a">
<input type="number" size=4 value=3 name="b">
</td>
</tr>
<tr>
<td align=center bgcolor=#ffffe4>
<font size=2>下のボタンを押してみてください。
</td>
</tr>
<tr>
<td align=center>
<input type="button" value=" + " onClick="_plus(this.form)">
<input type="button" value=" - " onClick="_minus(this.form)">
<input type="button" value=" x " onClick="a_multi_b(this.form)">
<input type="button" value=" / " onClick="_div(this.form)">
<input type="button" value=" ^ " onClick="_pow(this.form)">
</td>
</tr>
<tr>
<td align=center>
<input type "number" value=0 name="ans" size=9>
</td></tr></table>
</FORM>
</CENTER>
</BODY>
</HTML>
|