You are on page 1of 1

<html>

<head>
<title></title>
</head>
<script type="text/javascript">

function mostrarSeleccionado()
{
if (document.getElementById('radio1').checked)
{
n1 = parseInt(document.getElementById("Num1").value);
n2 = parseInt(document.getElementById("Num2").value);
document.getElementById("Num3").value = n1 + n2;
}

if (document.getElementById('radio2').checked)
{
n1 = parseInt(document.getElementById("Num1").value);
n2 = parseInt(document.getElementById("Num2").value);
document.getElementById("Num3").value = n1 - n2;
}

if (document.getElementById('radio3').checked)
{
n1 = parseInt(document.getElementById("Num1").value);
n2 = parseInt(document.getElementById("Num2").value);
document.getElementById("Num3").value = n1 * n2;
}
if (document.getElementById('radio4').checked)
{
n1 = parseInt(document.getElementById("Num1").value);
n2 = parseInt(document.getElementById("Num2").value);
document.getElementById("Num3").value = n1 / n2;
}

}
</script>
<body>
<form id="pant" name="pant">
Numero: <input type="text" name="Num1" id="Num1"><input type="radio" id="radio1"
name="estudios"> Sumar<br>
Numero: <input type="text" name="Num2" id="Num2"><input type="radio" id="radio2"
name="estudios"> Restar<br>
Resultado: <input type="text" name="Num3" id="Num3"><input type="radio"
id="radio3" name="estudios"> Multiplicar <br>
<input type="radio" id="radio4" name="estudios"> dividir <br>

<input type="button" value=" Calcular " onClick=mostrarSeleccionado()>

</form>
</body>
</html>

You might also like