値:
答え:

ソースは、以下の通りです。

<SCRIPT LANGUAGE="JavaScript">
<!-- Code hiding from here
function eachans(cal) {
	if (cal == 0) frm.result.value = Math.abs(frm.question.value);
	if (cal == 1) frm.result.value = Math.round(frm.question.value);
	if (cal == 2) frm.result.value = Math.sqrt(frm.question.value);
	if (cal == 3) frm.result.value = Math.sin(frm.question.value);
	if (cal == 4) frm.result.value = Math.cos(frm.question.value);
	if (cal == 5) frm.result.value = Math.tan(frm.question.value);
	if (cal == 6) frm.result.value = Math.log(frm.question.value);
	if (cal == 7) frm.result.value = Math.log(frm.question.value) / Math.log(10.0);
	if (cal == 8) frm.result.value = Math.exp(frm.question.value);
}
// end -->
</SCRIPT>

<FORM NAME="frm">
値:<INPUT TYPE="text" NAME="question" SIZE="30"><BR>
答え:<INPUT TYPE="text" NAME="result" SIZE="40"><BR>
<INPUT TYPE="button" NAME="abs" VALUE="abs" OnClick="eachans(0)">
<INPUT TYPE="button" NAME="round" VALUE="四捨五入" OnClick="eachans(1)">
<INPUT TYPE="button" NAME="sqrt" VALUE="sqrt" OnClick="eachans(2)">
<INPUT TYPE="button" NAME="sin" VALUE="sin" OnClick="eachans(3)">
<INPUT TYPE="button" NAME="cos" VALUE="cos" OnClick="eachans(4)">
<INPUT TYPE="button" NAME="tan" VALUE="tan" OnClick="eachans(5)">
<INPUT TYPE="button" NAME="log" VALUE="log" OnClick="eachans(6)">
<INPUT TYPE="button" NAME="log10" VALUE="log10" OnClick="eachans(7)">
<INPUT TYPE="button" NAME="exp" VALUE="exp" OnClick="eachans(8)"><BR>
</FORM>


JavaScriptの実験室に戻る
トップページに戻る