Muchas gracias y aquí dejo el código que hemos usado:
Cita:
<html>
<head>
<script>
function calcula (op) {
var o1 = document.getElementById("oper1");
op1=o1.value;
var o2 = document.getElementById("oper2");
op2=o2.value;
var res = 0;
if (op=="+")
{
res=parseInt(op1) + parseInt(op2);
}
else
{
if (op=="-")
{
res=op1 - op2
}
else
{
if (op=="*")
{
res=op1 * op2
}
else
{
if (op=="/")
{
res=op1 / op2
}
}
}
}
document.calculadora.result.value. = res
}
</script>
</head>
<body>
<section>
<form name="calculadora">
<input type="Text" name="oper1" id="oper1" value="0" size="14">
<br>
<br>
<input type="Text" name="oper2" id="oper2" value="0" size="14">
<br>
<br>
<input type="Button" name="" value=" + " onclick="calcula('+')">
<input type="Button" name="" value=" - " onclick="calcula('-')">
<input type="Button" name="" value=" * " onclick="calcula('*')">
<input type="Button" name="" value=" / " onclick="calcula('/')">
<br>
<br>
<input type="Text" name="result" id="tl" value="0" size="14">
</form>
</body>
</html>
<head>
<script>
function calcula (op) {
var o1 = document.getElementById("oper1");
op1=o1.value;
var o2 = document.getElementById("oper2");
op2=o2.value;
var res = 0;
if (op=="+")
{
res=parseInt(op1) + parseInt(op2);
}
else
{
if (op=="-")
{
res=op1 - op2
}
else
{
if (op=="*")
{
res=op1 * op2
}
else
{
if (op=="/")
{
res=op1 / op2
}
}
}
}
document.calculadora.result.value. = res
}
</script>
</head>
<body>
<section>
<form name="calculadora">
<input type="Text" name="oper1" id="oper1" value="0" size="14">
<br>
<br>
<input type="Text" name="oper2" id="oper2" value="0" size="14">
<br>
<br>
<input type="Button" name="" value=" + " onclick="calcula('+')">
<input type="Button" name="" value=" - " onclick="calcula('-')">
<input type="Button" name="" value=" * " onclick="calcula('*')">
<input type="Button" name="" value=" / " onclick="calcula('/')">
<br>
<br>
<input type="Text" name="result" id="tl" value="0" size="14">
</form>
</body>
</html>