Version compl�te: jsB@nk » Calcul » Calculatrice » Calculatrice de base 2
URL: https://www.javascriptbank.com/basic-calculator-2.html
Une autre base calculatrice script.
Version compl�te: jsB@nk » Calcul » Calculatrice » Calculatrice de base 2
URL: https://www.javascriptbank.com/basic-calculator-2.html
<script language="LiveScript"><!-- Hide javascriptfunction addChar(input, character){ if(input.value == null || input.value == "0") input.value = character else input.value += character}function cos(form){ form.display.value = Math.cos(form.display.value); }function sin(form){ form.display.value = Math.sin(form.display.value); }function tan(form){ form.display.value = Math.tan(form.display.value); }function sqrt(form){ form.display.value = Math.sqrt(form.display.value); }function ln(form){ form.display.value = Math.log(form.display.value); }function exp(form){ form.display.value = Math.exp(form.display.value); }function sqrt(form){ form.display.value = Math.sqrt(form.display.value); }function deleteChar(input){ input.value = input.value.substring(0, input.value.length - 1)}function changeSign(input){ // could use input.value = 0 - input.value, but let's show offsubstring if(input.value.substring(0, 1) == "-") input.value = input.value.substring(1, input.value.length) else input.value = "-" + input.value}function compute(form) { form.display.value = eval(form.display.value)}function square(form) { form.display.value = eval(form.display.value) *eval(form.display.value)}function checkNum(str) { for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i+1) if (ch < "0" || ch > "9") { if (ch != "/" && ch != "*" && ch != "+" && ch !="-" && ch != "." && ch != "(" && ch!= ")") { alert("invalid entry!") return false } } } return true}<!-- End of Calculator ---></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form><input name="display" value="0" size="25"><br><input type="button" value=" exp " onclick="if (checkNum(this.form.display.value)){ exp(this.form) }"><input type="button" value=" 7 " onclick="addChar(this.form.display, '7')"><input type="button" value=" 8 " onclick="addChar(this.form.display, '8')"><input type="button" value=" 9 " onclick="addChar(this.form.display, '9')"><input type="button" value=" / " onclick="addChar(this.form.display, '/')"><br><input type="button" value=" ln " onclick="if (checkNum(this.form.display.value)){ ln(this.form) }"><input type="button" value=" 4 " onclick="addChar(this.form.display, '4')"><input type="button" value=" 5 " onclick="addChar(this.form.display, '5')"><input type="button" value=" 6 " onclick="addChar(this.form.display, '6')"><input type="button" value=" * " onclick="addChar(this.form.display, '*')"><br><input type="button" value=" sqrt " onclick="if (checkNum(this.form.display.value)){ cos(this.form) }"><input type="button" value=" 1 " onclick="addChar(this.form.display, '1')"><input type="button" value=" 2 " onclick="addChar(this.form.display, '2')"><input type="button" value=" 3 " onclick="addChar(this.form.display, '3')"><input type="button" value=" - " onclick="addChar(this.form.display, '-')"><br><input type="button" value=" sq " onclick="if (checkNum(this.form.display.value)) { square(this.form) }"><input type="button" value=" 0 " onclick="addChar(this.form.display, '0')"> <input type="button" value=" . " onclick="addChar(this.form.display, '.')"> <input type="button" value=" +/- " onclick="changeSign(this.form.display)"><input type="button" value=" + " onclick="addChar(this.form.display, '+')"><br><input type="button" value=" ( " onclick="addChar(this.form.display, '(')"> <input type="button" value=" cos " onclick="if (checkNum(this.form.display.value)){ cos(this.form) }"><input type="button" value=" sin " onclick="if (checkNum(this.form.display.value)){ sin(this.form) }"><input type="button" value=" tan " onclick="if (checkNum(this.form.display.value)){ tan(this.form) }"><input type="button" value=" ) " onclick="addChar(this.form.display, ')')"> <br><input type="button" value=" Clear " onclick="this.form.display.value = 0 "><input type="button" value=" Back Space " onclick="deleteChar(this.form.display)"><input type="button" value=" Enter " name="enter" onclick="if (checkNum(this.form.display.value)) { compute(this.form) }"></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->