Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/07/2012, 10:01
carriofamily
 
Fecha de Ingreso: julio-2012
Mensajes: 19
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: selecionar opcion

muchas gracias por tu respuesta tan rapida pero lo que yo queria era que al seleccionar la opcion porcentage al lado del input num2 me saliera un porcien(%) y yo ya lo habia conseguido y funciona perfectamente en firefox pero cuando ago lo mismo en crhome no funciona,

pd: ahora he añadido q cuando seleciones cuadrado o bicuadrado quite el input num2

pongo el codigo de la paguina entera es un poco lioso perdon esque acabo de empezar

Código HTML:
<?php


session_start();

	
if($_SESSION['user']=="")
{
header("location: index.php");

}
?>
<!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>

<style type="text/css">
.num {
	border-top-width: medium;
	border-right-width: medium;
	border-bottom-width: medium;
	border-left-width: medium;
	border-right-style: solid;
	border-top-color: #F00;
	border-right-color: #F00;
	border-bottom-color: #F00;
	border-left-color: #F00;
}
.abajo {
	background-color: #FC7208;
	margin: auto;
	width: 682px;
	padding-top: 15px;
	padding-bottom: 15px;
	bottom: 100px;
}
footer {
	font-size: xx-large;
	color: #CCC;
	background-color: #FC7208;
	margin: auto;
	width: 682px;
	padding-top: 25px;
	padding-bottom: 25px;
	border-radius: 0px 0px 30px 30px;
	text-align: center;
	font-family: "Lucida Console", Monaco, monospace;
}

.basic {
	border-top-width: medium;
	border-right-width: medium;
	border-bottom-width: medium;
	border-left-width: medium;
	border-right-style: none;
	border-top-color: #F00;
	border-right-color: #F00;
	border-bottom-color: #F00;
	border-left-color: #F00;
}
body {
	background-image: url(http://us.cdn4.123rf.com/168nwm/kentoh/kentoh1002/kentoh100200114/6372054-arte-de-fondo-de-patron-de-madera-como-elemento-de-diseno.jpg);
	background-repeat: repeat;
}
.num2 {
	border-top-width: medium;
	border-right-width: medium;
	border-bottom-width: medium;
	border-left-width: medium;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: solid;
	border-top-color: #F00;
	border-right-color: #F00;
	border-bottom-color: #F00;
	border-left-color: #F00;
}
table {
	border: medium solid #666;
	height: auto;
	width: auto;
}
.igual {
	border-top-width: medium;
	border-right-width: medium;
	border-bottom-width: medium;
	border-left-width: medium;
	border-left-style: solid;
	border-top-color: #F00;
	border-right-color: #F00;
	border-bottom-color: #F00;
	border-left-color: #F00;
}
.result {
	color: #000;
	font-family: Digital-7;
	font-size: 100px;
	text-align: center;
	font-style: oblique;
	margin: auto;
	position: relative;
	top: 95px;
}
#button {
	margin: 0px;
	height: 40px;
}
.bajoigu {
	border-top-width: medium;
	border-right-width: medium;
	border-bottom-width: medium;
	border-left-width: medium;
	border-left-style: solid;
	border-top-color: #F00;
	border-right-color: #F00;
	border-bottom-color: #F00;
	border-left-color: #F00;
	border-top-style: none;
	border-right-style: none;
}
.calcup {
	background-image: url(imagenes/XAMPP%20Control.png);
	background-repeat: repeat-x;
	height: 230px;
	width: 500px;
	margin: auto;
}
.laterales {
	background-image: url(imagenes/laterales.png);
	background-repeat: no-repeat;
	margin: auto;
	width: 682px;
	border-radius: 30px 30px 0px 0px;
	height: 230px;
}
.borde {
	border-top-width: medium;
	border-right-width: medium;
	border-bottom-width: medium;
	border-left-width: medium;
	border-right-style: solid;
	border-top-color: #F00;
	border-right-color: #F00;
	border-bottom-color: #F00;
	border-left-color: #F00;
}
footer a {
	font-family: "Lucida Console", Monaco, monospace;
	font-size: 36px;
	font-weight: bold;
	color: #000;
	text-decoration: none;
	text-align: center;

	
}

</style>
</head>

<body><div class="laterales"><div class="calcup">
<div class="result"><?php 
	
$num=$_POST['num'];
$num2=$_POST['num2'];
$basic=$_POST['basic'];


if($basic=='suma'){
	$ok= $num + $num2;
}elseif($basic=='resta'){
	$ok= $num - $num2;
}elseif($basic=='multi'){
	$ok= $num * $num2;
}elseif($basic=='div'){
	$ok= $num / $num2;
}elseif($basic=='cuadrado'){
	$ok= $num * $num;
}elseif($basic=='bicuadrado'){
	$ok=$num * $num * $num * $num;
}
elseif($basic=='porcent'){
	$ok=($num2 / 100) * $num;

}
echo $ok;?></div>
</div></div><div class="abajo">
<form action="calculator.php" method="post"><center><table width="423">
      <tr>
        <td  class="num"width="120"><center><input type="text" name='num' id="textfield" size="10" value="<?php echo $num; ?>" /></center></td>
        <td class="basic" width="112"><center><select name="basic" >
          <option value="suma" onclick="document.getElementById('num2').style.display='table-cell';   document.getElementById('porcien').style.display='none';">+ Sumar</option>
          <option value="resta" onclick="document.getElementById('num2').style.display='table-cell';   document.getElementById('porcien').style.display='none';">- Restar</option>
          <option value="multi" onclick="document.getElementById('num2').style.display='table-cell';   document.getElementById('porcien').style.display='none';">X Multiplicar</option>
          <option value="div" onclick="document.getElementById('num2').style.display='table-cell';   document.getElementById('porcien').style.display='none';">/ Dividir</option>
          <option value="cuadrado" onclick="document.getElementById('num2').style.display='none';     document.getElementById('porcien').style.display='none';">x2</option>
          <option value="bicuadrado" onclick="document.getElementById('num2').style.display='none'; document.getElementById('porcien').style.display='none';">x4</option>
          <option value="porcent" onclick="document.getElementById('porcien').style.display='inline'; document.getElementById('num2').style.display='table-cell';">% Porcentaje</option>
        </select></center>
        </td>
        <td id="num2" width="127" class="num2" ><center><input type="text" name="num2" size="10" value="<?php echo $num2; ?>"/><b style="display:none" id="porcien"> %</b></center></td>
        <td width="38" class="igual"><center><input type="submit" name="button" id="button" value="=" /></center></td>
        
      </tr>
      <div class="borde"> </div>
  </table></center></form>
</div><footer><a href="usuario.php">Regresar</a>/<a href="salir.php">salir</a></footer>
</body>
</html>