Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/06/2013, 15:35
Avatar de alberto510a
alberto510a
 
Fecha de Ingreso: abril-2013
Mensajes: 351
Antigüedad: 11 años
Puntos: 35
Respuesta: Sumar y restar (solo suma)

Hola, aquí te hice un ejemplo:

Código HTML:
Ver original
  1. <input type="text" id="8" value="3"/>
  2. <input type="text" id="5" value="1"/>
  3. <input type="text" id="resultado"/>
  4. <button onclick="calcular();">Resultado</button>

Código Javascript:
Ver original
  1. function calcular(){
  2. var ocho = parseInt(document.getElementById('8').value);
  3. var cinco = parseInt(document.getElementById('5').value);
  4. var resultado = ocho - cinco;
  5. document.getElementById('resultado').value = resultado;
  6. }

Saludos!
__________________
No hay preguntas tontas, sino tontos que no preguntan.