Calculadora Javascript
Publicado por Perfil removido (última atualização em 01/09/2010)
[ Hits: 12.711 ]
Fiz uma calculadora em javascript, mas não consegui que ela fizesse mais de uma conta em uma execução. Sendo assim para fazer mais de uma conta em uma execução é preciso apertar AC para zerá-la. Aqui está!
<HTML> <HEAD> <TITLE>Calculadora - Caio Augusto</TITLE> <style type="text/css"> .botao{ width:100%; } </style> <script> /* E-mail:franknatus@hotmail.com WebSite:http://www.moneygratis.net Twitter:@lennonrangues ------------------------------ Aprenda! Aprimore! Compartilhe! */ var primeiro=0; var lastcommand; function escrever(valor) { window.document.tela.screen.value=window.document.tela.screen.value+valor; } function salvavalor(nome) { if(primeiro==0) { primeiro=window.document.tela.screen.value; window.document.tela.screen.value=""; lastcommand=nome; } else { switch(lastcommand) { case '+': window.document.tela.screen.value=eval(primeiro+'+'+window.document.tela.screen.value); primeiro=window.document.tela.screen.value; return primeiro; break; case '-': window.document.tela.screen.value=primeiro-window.document.tela.screen.value; primeiro=window.document.tela.screen.value; return primeiro; break; case '/': window.document.tela.screen.value=(primeiro)/(window.document.tela.screen.value); primeiro=window.document.tela.screen.value; return primeiro; break; case '*': window.document.tela.screen.value=primeiro*window.document.tela.screen.value; primeiro=window.document.tela.screen.value; return primeiro; break; } } } </script> </HEAD> <BODY> <table valign="middle" align="center" border="1"> <tr> <td colspan="4"><form name="tela"><input type="text" size="20" name="screen"><input type="button" value="AC" onClick="primeiro=0;window.document.tela.screen.value='';"></form></td> </tr> <tr> <td><input type="button" onClick="escrever(this.value);" value="1" class="botao"></td> <td><input type="button" value="2" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="3" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="+" class="botao" OnClick="salvavalor(this.value);"></td> </tr><tr> <td><input type="button" value="4" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="5" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="6" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="-" class="botao" OnClick="salvavalor(this.value);"></td> </tr><tr> <td><input type="button" value="7" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="8" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="9" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="/" class="botao" OnClick="salvavalor(this.value);"></td> </tr><tr> <td><input type="button" value="." onClick="escrever(this.value);" class="botao"</td> <td><input type="button" value="0" onClick="escrever(this.value);" class="botao"></td> <td><input type="button" value="=" class="botao" OnClick="window.document.tela.screen.value=salvavalor(lastcommand);"></td> <td><input type="button" value="*" class="botao" OnClick="salvavalor(this.value);"></td> </tr> </table> </BODY> </HTML>
Processamento de vídeo (stream effects)
Manda Mensagem Icq ao clicar no link
Naum mostra source e nem deixa selecionar!!
Jogo Snake feito em TypeScript e Phaser 2 (com gráficos)
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Atualizar Debian Online de uma Versão para outra
Instalar driver Nvidia no Debian 13
Redimensionando, espelhando, convertendo e rotacionando imagens com script
Debian 13 Trixie para Iniciantes
Convertendo pacotes DEB que usam ZSTD (Padrão Novo) para XZ (Padrão Antigo)
Debian 13 "trixie&... lançado! (44)
Rust é o "C da nossa geração"? (3)
Gerenciador de arquivos é finalizado ao abrir pasta específica (2)