»
Tiếng AnhTiếng PhápTiếng Việt

In - Máy tính cao cấp - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Tính toán » Máy tính » Máy tính cao cấp
URL: https://www.javascriptbank.com/high-tech-calculator.html

Máy tính cao cấp © JavaScriptBank.comHiệu ứng tạo một máy tính với các chức năng cao cấp như tính căn, làm tròn, sin, cos... bên cạnh các chức năng phép toán cơ bản.

Phiên bản đầy đủ: jsB@nk » Tính toán » Máy tính » Máy tính cao cấp
URL: https://www.javascriptbank.com/high-tech-calculator.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Kenny Aral ([email protected] )<!-- Beginfunction DOit() {var userinput = document.calc.input.value;document.calc.input.value = eval(userinput);}function plus() {document.calc.input.value += '+';}function minus() {document.calc.input.value += '-';}function mult() {document.calc.input.value += '*';}function div() {document.calc.input.value += '/';}function decimal() {document.calc.input.value += '.';}function openp() {document.calc.input.value += '(';}function closep() {document.calc.input.value += ')';}function num(x) {document.calc.input.value += x;}function recip() {document.calc.input.value = 1/(document.calc.input.value);}function square() {document.calc.input.value =(document.calc.input.value)*(document.calc.input.value);}function cube() {document.calc.input.value =(document.calc.input.value)*(document.calc.input.value)*(document.calc.input.value);}function pi() {document.calc.input.value += Math.PI;}function plus_or_minus() {document.calc.input.value *= -1;}function percent() {document.calc.input.value *= .01;}function sqrt() {document.calc.input.value = Math.sqrt(document.calc.input.value);}function power() {var np = prompt("What power do you want? Must be a number!","")document.calc.input.value = Math.pow(document.calc.input.value, np);}function cos() {document.calc.input.value = Math.cos(document.calc.input.value);}function sin() {document.calc.input.value = Math.sin(document.calc.input.value);}function tan() {document.calc.input.value = Math.tan(document.calc.input.value);}function Round() {document.calc.input.value = parseInt(document.calc.input.value);}// 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="calc"><TABLE WIDTH="55" HEIGHT="65" CELLSPACING="2"CELLPADDING="5" BORDER="1"><tr><td><INPUT TYPE="text" NAME="input" SIZE="20" MAXLENGTH="30"class="disp"><td><INPUT TYPE="button" VALUE=" ^ " onClick="power()"class="btswhite"><td><INPUT TYPE="button" VALUE=" C "onClick="document.calc.input.value = ''; " class="btswhite"><td><INPUT TYPE="button" VALUE="Cos" onClick="cos()"class="btsred"></tr><tr><td><INPUT TYPE="button" Value=" 1 " class="btsblue"onClick="num(1)">  <INPUT TYPE="button" VALUE=" 2 " class="btsblue"onClick="num(2)">  <INPUT TYPE="button" VALUE=" 3 " class="btsblue"onClick="num(3)">  <INPUT TYPE="button" VALUE=" ( " class="btswhite"onClick="openp()"><td><INPUT TYPE="button" VALUE=" + " onClick="plus()"class="btswhite"><td><INPUT TYPE="button" VALUE="sqrt" onClick="sqrt()"class="btsred"><td><INPUT TYPE="button" VALUE="Sin " onClick="sin()"class="btsred"></tr><tr><td><INPUT TYPE="button" Value=" 4 " class="btsblue"onClick="num(4)">  <INPUT TYPE="button" Value=" 5 " class="btsblue"onClick="num(5)">  <INPUT TYPE="button" Value=" 6 " class="btsblue"onClick="num(6)">  <INPUT TYPE="button" NAME="closeprth" Value=" ) " class="btswhite"onClick="closep()"><td><INPUT TYPE="button" VALUE=" - " onClick="minus()"class="btswhite"><td><INPUT TYPE="button" Value=" 1/x" class="btsred"onClick="recip()"><td><INPUT TYPE="button" VALUE="Tan" onClick="tan()"class="btsred"></tr><tr><td><INPUT TYPE="button" Value=" 7 " class="btsblue"onClick="num(7)">  <INPUT TYPE="button" Value=" 8 " class="btsblue"onClick="num(8)">  <INPUT TYPE="button" Value=" 9 " class="btsblue"onClick="num(9)">  <INPUT TYPE="button" VALUE=" % " onClick="percent()"class="btswhite"><td><INPUT TYPE="button" VALUE=" * " onClick="mult()"class="btswhite"><td><button style="background: #999999; color: #FF0000;font-weight: bold"onClick="square()">  x<sup>2</sup> </button><td><INPUT TYPE="button" VALUE="Rnd" onClick="Round()"class="btsred"></tr><tr><td><INPUT TYPE="button" Value=" 0 " class="btsblue"onClick="num(0)">  <INPUT TYPE="button" Value=" . " class="btsblue"onClick="decimal()">  <INPUT TYPE="button" VALUE=" +/- " onClick="plus_or_minus()"class="btsblue">  <INPUT TYPE="button" Value=" Pi " class="btsblue" onClick="pi()"><td><INPUT TYPE="button" VALUE=" / " onClick="div()"class="btswhite"><td><button style="background: #999999; color: #FF0000;font-weight: bold"onClick="cube()">  x<sup>3</sup> </button><td><INPUT TYPE="button" VALUE=" = " onClick="DOit()"class="btsred"></tr></TABLE></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->