Codigo javascrip

Páginas: 4 (878 palabras) Publicado: 8 de julio de 2010
CODIGO FUENTE CALCULADORA

<html>
<head><title>Calculadora</title>
<script language="JavaScript">
<!-- Aqui se oculta el script a los visualizadores que nosoportan JavaScript
// keep track of whether we just computed display.value
function pushStack(form)
{
form.stack.value = form.display.value
form.display.value = 0
}
//
// Definea function to add a new character to the display
//
function addChar(input, character)
{
// auto-push the stack if the last value was computed
var computed = false
if(computed) {pushStack(input.form)
computed = false
}
// make sure input.value is a string
if(input.value == null || input.value == "0")
input.value = character
else
input.value += character}
function deleteChar(input)
{
input.value = input.value.substring(0, input.value.length - 1)
}
function add(form)
{
form.display.value = form.stack.value + form.display.valuecomputed = true
}
function subtract(form)
{
form.display.value = form.stack.value - form.display.value
computed = true
}
function multiply(form)
{
form.display.value =form.stack.value * form.display.value
computed = true
}
function divide(form)
{
var divisor = parseFloat(form.display.value)
if(divisor == 0) {
alert("Don't divide by zero, pal...");return
}
form.display.value = form.stack.value / divisor
computed = true
}
function changeSign(input)
{
// could use input.value = 0 - input.value, but let's show off substringif(input.value.substring(0, 1) == "-")
input.value = input.value.substring(1, input.value.length)
else
input.value = "-" + input.value
}
<!-- done hiding from old browsers --></script>
</head>
<body bgcolor="00FFFF">
<h1>Calculadora. Ejemplo de Javascript</h1>
Esta calculadora trabaja de una forma un tanto diferente a como es...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • javascrip
  • javascrip
  • Curso De Javascrip
  • Javascrip
  • Javascrip
  • Valiacion formularios javascrip
  • Codigo
  • Codigos

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS