
Calculadora super basica
JavaScript
Actualizado el 17 de Marzo del 2018 por Anonymous (35 códigos) (Publicado el 8 de Marzo del 2017)
11.217 visualizaciones desde el 8 de Marzo del 2017
<html>
<head>
<title>Calculadora basica</title>
<style>
input[type="button"]{
width:40px;
}
</style>
</head>
<body>
<form name="f1">
<input type="text" name="txtcaja"><br>
<input type="button" onclick="escribir('1')" value="1">
<input type="button" onclick="escribir('2')" value="2">
<input type="button" onclick="escribir('3')" value="3"> <input type="button" onclick="escribir('+')" value="+"><br>
<input type="button" onclick="escribir('4')" value="4">
<input type="button" onclick="escribir('5')" value="5">
<input type="button" onclick="escribir('6')" value="6"> <input type="button" onclick="escribir('-')" value="-"><br>
<input type="button" onclick="escribir('7')" value="7">
<input type="button" onclick="escribir('8')" value="8">
<input type="button" onclick="escribir('9')" value="9"> <input type="button" onclick="escribir('*')" value="*"><br>
<input type="button" onclick="escribir('0')" value="0">
<input type="button" onclick="escribir('.')" value=".">
<input type="button" onclick="document.f1.reset()" value="C">
<input type="button" onclick="calcula()"value="="><br>
</form>
<script>
function escribir(n){
var caja = document.f1.txtcaja.value;
document.f1.txtcaja.value=caja + n;
}
function calcula(){
var caja = document.f1.txtcaja.value;
ecuacion = eval(caja);
document.f1.txtcaja.value=ecuacion;
}
</script>
</body>
</html>
No hay comentarios