Ver Mensaje Individual
  #6 (permalink)  
Antiguo 23/03/2011, 12:30
Avatar de jotaincubus
jotaincubus
 
Fecha de Ingreso: mayo-2005
Ubicación: Medellin - Colombia
Mensajes: 1.797
Antigüedad: 19 años, 8 meses
Puntos: 394
Respuesta: Switch y Radio Button en PHP

Aqui esta el codigo completo funcionando, te lo arregle todo porque colocaste mucho de tu parte... Estudialo y mira los cambios para que aprendas de los errores.

Código PHP:
<?php
if(isset($_POST['submit'])){
switch(
$opcion)
{
case
"suma":
$result=$num1+$num2;
echo 
"<br> El resultado de ".$num1" + " .$num2 ." = ".$result;
break;
case
"resta":
$result=$num1-$num2;
echo 
"<br> El resultado de ".$num1" - " .$num2 ." = ".$result;
break;
case
"mult":
$result=$num1*$num2;
echo 
"<br> El resultado de ".$num1" * " .$num2 ." = ".$result;
break;
case
"div":
$result=$num1/$num2;
echo 
"<br> El resultado de ".$num1" / " .$num2 ." = ".$result;
break;
default:
echo
"selecciona una operación aritmética";
break;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin tÃ*tulo</title>
</head>

<body>
<form name="forma" method="post" action="">
<table>
<tr>
<td>
Numero 1 <input type="text" name="num1" />
<br />
Numero 2 <input type="text" name="num2" />
<br />
</td>
<td>
<input type="radio" name="opcion" value="suma" /> Suma <br />
<input type="radio" name="opcion" value="resta" />Resta<br />
<input type="radio" name="opcion" value="mult" />Multiplicación<br />
<input type="radio" name="opcion" value="div" />Division<br />
</td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Calcular"  /></td>
<td>&nbsp;</td>
</tr>

</table>
</form>
</body>
</html>
__________________
Por que existe gente que no agradece después de que se le ha brindado tiempo y ayuda ???