23/03/2011, 11:18
|
| | Fecha de Ingreso: julio-2008
Mensajes: 92
Antigüedad: 16 años, 6 meses Puntos: 0 | |
Respuesta: Switch y Radio Button en PHP Soy yo de Nuevo.
Modifique mi codigo asi:
<!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>
<table border="1" width="60%" cellspacing="1" cellpadding="20" border="0" align="center">
<tr>
<td>
Numero 1 <input type="text" name="num1" />
<br />
Numero 2 <input type="text" name="num2" />
<br />
</td>
<td>
<form name="Forma" method="post" action="">
<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>
</table>
<?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;
}
}
?>
<input type="submit" value="calcular" />
</form>
</body>
</html>
como puedo crear un label o algo asi para que me imprima la respuesta, gracias por la ayuda |