Tal vez te sirva de algo:
Código Javascript
:
Ver original<script language="javascript">
/*aritmética básica*/
function sumar(a,b){
var a=document.getElementById('a');
var b=document.getElementById('b');
a=parseFloat(a.value);
b=parseFloat(b.value);
var result1=document.getElementById('suma');
result1.value=a+b;
}
function restar(a,b){
var a=document.getElementById('a');
var b=document.getElementById('b');
a=parseFloat(a.value);
b=parseFloat(b.value);
var result2=document.getElementById('resta');
result2.value=a-b;
}
function producto(a,b){
var a=document.getElementById('a');
var b=document.getElementById('b');
a=parseFloat(a.value);
b=parseFloat(b.value);
var result3=document.getElementById('produce');
result3.value=a*b;
}
function division(a,b){
var a=document.getElementById('a');
var b=document.getElementById('b');
a=parseFloat(a.value);
b=parseFloat(b.value);
var result4=document.getElementById('divide');
result4.value=a/b;
}
function limpiar(){
document.getElementById('a').value="";
document.getElementById('b').value="";
document.getElementById('suma').value="";
document.getElementById('resta').value="";
document.getElementById('produce').value="";
document.getElementById('divide').value="";
}
</script>
<body>
Número 1: <input type="text" id="a" value=""/><br/>
Número 2: <input type="text" id="b" value=""/><br/>
Suma: <input type="text" id="suma" name="suma" value=""/><button onClick="javascript:sumar(document.getElementById('a'),document.getElementById('b'));" class="c-icon" title="sumar">Suma</button><br/>
<br/>
Resta: <input type="text" id="resta" name="resta" value=""/><button onClick="javascript:restar(document.getElementById('a'),document.getElementById('b'));" class="c-icon" title="restar">Resta</button><br/>
<br/>
Producto: <input type="text" id="produce" name="produce" value=""/><button onClick="javascript:producto(document.getElementById('a'),document.getElementById('b'));" class="c-icon" title="multiplicar">Producto</button><br/>
<br/>
División: <input type="text" id="divide" name="divide" value=""/>
<button onClick="javascript:division(document.getElementById('a'),document.getElementById('b'));" class="c-icon" title="dividir">División</button><br/>
<br/>
<button onClick="javascript:limpiar();" class="c-icon" title="activar evento">Limpiar</button><br/></body>