»
EnglishFrenchVietnamese

Print - Advanced Calculator - JavaScriptBank.com

Full version: jsB@nk » Calculation » Calculator » Advanced Calculator
URL: https://www.javascriptbank.com/calculator-hamad-belshalat.html

Advanced Calculator © JavaScriptBank.comThis is a different script to create a calculator code with memorial function.

Full version: jsB@nk » Calculation » Calculator » Advanced Calculator
URL: https://www.javascriptbank.com/calculator-hamad-belshalat.html



CSS
<style type="text/CSS"><!--.button{border-width:1pt;border-style:solid;border-color:#CCCCCC;background-color:#F0F0F0}.h1{font-family:Arial;font-size:24pt;font-weight:bold}.h2{font-family:Arial;font-size:10pt;font-weight:100}--></style><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<script language="JavaScript" type="text/JavaScript">function changeBG(){var num = Math.round(Math.random() * 999999);document.fgColor = "#" + num + "";}function insert(number){var num1, num2, num3, num4, num5, num6, num7, num8, num9;num1 =  document.forms[0].value1;num2 =  document.forms[0].value2;num3 =  document.forms[0].value3;num4 =  document.forms[0].value4;num5 =  document.forms[0].value5;num6 =  document.forms[0].value6;num7 =  document.forms[0].value7;num8 =  document.forms[0].value8;num9 =  document.forms[0].value9;var num = document.forms[0].value.value;var svalue = document.forms[0].svalue.value;if(num != "The answer will be very long."){     if (number == "status") {window.status = "Number length: "+num.length;}     if (number == ".") {document.forms[0].value.value += ".";document.forms[0].svalue.value+="."}     if (number == "0") {document.forms[0].value.value += 0;document.forms[0].svalue.value+=0}     if (number == "1") {document.forms[0].value.value += 1;document.forms[0].svalue.value+=1}     if (number == "2") {document.forms[0].value.value += 2;document.forms[0].svalue.value+=2}     if (number == "3") {document.forms[0].value.value += 3;document.forms[0].svalue.value+=3}     if (number == "4") {document.forms[0].value.value += 4;document.forms[0].svalue.value+=4}     if (number == "5") {document.forms[0].value.value += 5;document.forms[0].svalue.value+=5}     if (number == "6") {document.forms[0].value.value += 6;document.forms[0].svalue.value+=6}     if (number == "7") {document.forms[0].value.value += 7;document.forms[0].svalue.value+=7}     if (number == "8") {document.forms[0].value.value += 8;document.forms[0].svalue.value+=8}     if (number == "9") {document.forms[0].value.value += 9;document.forms[0].svalue.value+=9}     if (number == "*") {document.forms[0].value.value += document.forms[0].multi.value;document.forms[0].svalue.value+=" * "}     if (number == "/") {document.forms[0].value.value += document.forms[0].divide.value;document.forms[0].svalue.value+=" / "}     if (number == "-") {document.forms[0].value.value += document.forms[0].minus.value;document.forms[0].svalue.value+=" - "}     if (number == "+") {document.forms[0].value.value += document.forms[0].add.value;document.forms[0].svalue.value+=" + "}     if (number == "%") {document.forms[0].value.value += document.forms[0].modulus.value;document.forms[0].svalue.value+=" % "}     if (number == "=") {document.forms[0].value.value = eval ( document.forms[0].svalue.value )     if (svalue.length > 30){document.forms[0].value.value = "You typed a very long integer.";return;}     }     if (number == "C") {document.forms[0].value.value = "";document.forms[0].svalue.value = ""}     if (number == "(") {document.forms[0].value.value += "(";document.forms[0].svalue.value += "("}     if (number == ")") {document.forms[0].value.value += ")";document.forms[0].svalue.value += ")"}     if (number == "M+"){if (num.length > 18){document.forms[0].value.value = "You typed a very long integer."}else if(num.length == ""){document.forms[0].value.value = "Nothing to set in memory."}else if(num.length < 111111111111111111){document.getElementById("mem").innerHTML = " Memory: <span style='color:#FF0000'>"+document.forms[0].value.value+"</span> ";document.forms[0].memory.value = document.forms[0].value.value;document.getElementById("mem").style.cursor="pointer"}else{alert("Error!")}}     if (number == "M-"){document.getElementById("mem").innerHTML = "&nbsp;";document.forms[0].memory.value = document.forms[0].value.value;document.getElementById("mem").style.cursor="default";document.forms[0].memory.value = ""}     if (number == "+/-"){     var Num = document.forms[0].value.value;     if(Num == Num){      document.forms[0].svalue.value = "-"+Num+"";}     if(Num != Num) {document.forms[0].svalue.value = "+"+Num+"";}                  }     var x;     var y;     var n1 = Math.round(Math.random() * 5604);     var n2 = Math.round(Math.random() * 5638);     if(number == "x"){x = prompt ("Type the value of x:",n1);document.forms[0].value.value += "x";document.forms[0].svalue.value+=x; if(x == null){}}     if(number == "y"){y = prompt ("Type the value of y:",n2);document.forms[0].value.value += "y";document.forms[0].svalue.value+=y; if(y == null){}}     if(number == "ran"){     var random = Math.round(Math.random() * 3000);     document.forms[0].value.value += random;document.forms[0].svalue.value += random;}     if(number == ">"){document.forms[0].value.value += " > ";document.forms[0].svalue.value+=">"}     if(number == "<"){document.forms[0].value.value += " < ";document.forms[0].svalue.value+="<"}     if(number == "back"){var num1 = document.forms[0].value.value;var num2 = document.forms[0].svalue.value;if(num1.indexOf("x") == -1 == false){insert("C")}                                                                                                             if(num1.indexOf("y") == -1 == false){insert("C")}                                                                                                             if(num1.indexOf("x") == -1 == false                                                                                                             || num2.indexOf("y") == -1 == false){insert("C")}     else {     document.forms[0].value.value = document.forms[0].value.value.substring(0, document.forms[0].value.value.length - 1);document.forms[0].svalue.value = document.forms[0].svalue.value.substring(0, document.forms[0].svalue.value.length - 1)}}     if(number == "E"){     var ran = Math.round(Math.random() * 100);     var myvalue = document.forms[0].svalue.value;     value = prompt ("Edit your value:",myvalue);     if(value == null){return;}      document.forms[0].value.value = value;document.forms[0].svalue.value = value}     if(number == ","){document.forms[0].value.value += " , ";document.forms[0].svalue.value += " , "}else {}}}function addnum(){document.forms[0].value.value += document.forms[0].memory.value;}function memory(){var num = document.forms[0].value.value;var num2 = document.forms[0].svalue.value;if(num == "" && num2 == ""){document.getElementById('mem').innerHTML = "&nbsp;"}else {document.getElementById('mem').innerHTML = ' Memory: <span style=color:#FF0000>'+document.forms[0].memory.value+'</span> ';}}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<body onload="memory();changeBG()" onclick=";insert('status')" onunload="changeBG()" text="#145415"><form action="#" method="get"><table id="calculator" cellpadding="5" cellspacing="4" border="1" bordercolor="#cccccc" bgcolor="#f0f0f0" style="position: relative;display: block;"><tbody><tr><td align=center><input type="text" size="27" onfocus="select()" name="value" value="" style="border: 1pt solid rgb(207, 207, 207); font-size: 8px; background-color: rgb(255, 255, 255); font-family: MS Sans Serif;" readonly="readonly"></td></tr><tr><td align="center"><hr color="#CCCCCC"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value1" value=" 0 " onclick="insert('0')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value1" value=" 1 " onclick="insert('1')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value2" value=" 2 " onclick="insert('2')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value3" value=" 3 " onclick="insert('3')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value4" value=" 4 " onclick="insert('4')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value5" value=" 5 " onclick="insert('5')"><br><br><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value6" value=" 6 " onclick="insert('6')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value7" value=" 7 " onclick="insert('7')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value8" value=" 8 " onclick="insert('8')"><input type="button" class="button" style="color: rgb(0, 0, 221);" name="value9" value=" 9 " onclick="insert('9')"><input type="button" class="button" style="color: rgb(106, 202, 170);" name="valuex" value=" x " onclick="insert('x')"><input type="button" class="button" style="color: rgb(106, 202, 170);" name="valuey" value=" y " onclick="insert('y')"><br><br><input type="button" class="button" name="" value=" Edit " style="color: rgb(204, 204, 0);" onclick="insert('E')"><input type="button" class="button" style="color: rgb(0, 170, 204);" name="multi" value=" × " onclick="insert('*')"><input type="button" class="button" style="color: rgb(0, 170, 204);" name="divide" value=" ÷ " onclick="insert('/')"><input type="button" class="button" style="color: rgb(0, 170, 204);" name="add" value=" + " onclick="insert('+')"><input type="button" class="button" style="color: rgb(0, 170, 204);" name="minus" value=" - " onclick="insert('-')"><input type="button" class="button" style="color: rgb(0, 170, 204);" name="modulus" value=" % " onclick="insert('%')"><br><br><input type="button" class="button" name="point" value=" . " onclick="insert('.')"><input type="button" class="button" name="equal" style="color: rgb(0, 0, 255);" value=" = " onclick="insert('=')"><input type="button" class="button" name="" value="+/-" style="color: rgb(160, 86, 140);" onclick="insert('+/-')"><input type="button" class="button" name="" value=" ( " style="color: rgb(0, 0, 255);" onclick="insert('(')"><input type="button" class="button" name="" value=" ) " style="color: rgb(0, 0, 255);" onclick="insert(')')"><input type="button" class="button" style="color: rgb(170, 0, 170);" name="b" value=" &#8592; " onclick="insert('back')"><input type="button" class="button" name="" value=" C " style="color: rgb(204, 0, 0);" onclick="insert('C')"><br><br><input type="button" class="button" name="" value="," style="color: rgb(0, 0, 0); font-family: Tahoma;" onclick="insert(',')"><input type="button" class="button" name="" value=" R " style="color: rgb(186, 186, 187);" onclick="insert('ran')"><input type="button" class="button" style="color: rgb(255, 0, 192);" name="&lt;" value=" &lt; " onclick="insert('<')"><input type="button" class="button" style="color: rgb(255, 0, 192);" name="&gt;" value=" &gt; " onclick="insert('>')"><input type="button" class="button" name="" value=" M+ " style="color: rgb(204, 0, 0);" onclick="insert('M+')"><input type="button" class="button" name="" value=" M- " style="color: rgb(204, 0, 0);" onclick="insert('M-')"><br>&nbsp;<div style="border: 1pt solid rgb(207, 207, 207); color: rgb(0, 0, 0); font-size: 8pt; font-family: MS Sans Serif; cursor: default; background-color: rgb(255, 255, 255);" id="mem" onclick="addnum()">&nbsp;</div><input type="hidden" name="memory" value=""><input type="hidden" name="svalue" value="1"><hr color="#CCCCCC"></td></tr><tr><td align=center><div class="h2"><small>Made by <span id="Hamad">Hamad Belshalat</span>.</small></div></td></tr></tbody></table></form></body><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->