
17/09/2013, 14:51
|
| | Fecha de Ingreso: septiembre-2013 Ubicación: San Juan, Argentina
Mensajes: 8
Antigüedad: 11 años, 5 meses Puntos: 0 | |
PHP- No entra al case del Switch Hola gente!..me presento..mi nombre es Martin y estoy teniendo un problema, como dice el titulo de este tema, tengo un switch el cual tiene varios 'case' funciona todos menos el que dice 'Aceptar'; entra unicamente al segundo click, es decir, hago click y nopasa nada ni siquiera entra al switch, luego hago nuevamente click y entra. No tengo idea de que es lo que puede ser ...estoy anodadado ..  ahi les paso el codigo para que le den una mirada y me puedan sugerir algunas soluciones!!..desde ya muchas Gracias!!..
Código:
<!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=iso-8859-1" />
<title>Listas de Productos - Indice</title>
<script type="text/javascript" src ="funciones.js"> </script>
<link rel="stylesheet" type="text/css" href="CSS/style.css" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include("conexion.php");
include("Funciones.php");
$band=false;
$habCampoVacio="selected";
$habOpciones="";
$selected="selected";
echo "Boton: ".$_POST[boton]."<br/>";
switch($_POST['boton'])
{
case 'Ver Lista':
$sql="SELECT * FROM articulosLista where idLista='$_POST[Lista]'";
$resulL=mysql_query($sql);
$band=true;
$habOpciones="selected";
$habCampoVacio="";
break;
case 'Crear Lista':
if($_POST[CrearLista]!=null) /*Agrego la tabla a listas*/
{
$sql="Insert INTO listas (nombre) Values ('$_POST[CrearLista]')";
$res=mysql_query($sql);
/*Selecciono el id de la tabla creada*/
$idLista="Select id From listas where nombre='$_POST[CrearLista]'";
$result=mysql_query($idLista);
$id=mysql_fetch_array($result);
//echo "ID lista: ".$id[id];
/* Selecciono todos los Articulos*/
$sqlA="Select * From articulos where Baja=0";
$resA=mysql_query($sqlA);
while($row=mysql_fetch_array($resA)) /* y los alamaceno en la tabla creada*/
{
$sqlL="INSERT INTO articulosLista (idLista, idArt, costo) Values ('$id[id]','$row[id]','$row[costo]')";
$resu=mysql_query($sqlL);
}
}
break;
case 'Eliminar':
$sqld="Delete from articulosLista where idLista='$_POST[EliminarLista]'";
$res=mysql_query($sqld);
// echo $sqld;
$sql="Delete from listas where id='$_POST[EliminarLista]'";
$res=mysql_query($sql);
// echo $sql;
break;
case '_':
$habOpciones="selected";
$habCampoVacio="";
$sqlE="DELETE From articulosLista Where id= '$_POST[oculto]'";
if($res=mysql_query($sqlE))
{
$sql="SELECT * FROM articulosLista where idLista='$_POST[Lista]'";
$resulL=mysql_query($sql);
$band=true;
}
break;
case 'Aceptar':
$sqlAceptar="Select * From articulosLista Where idLista='$_POST[Lista]'";
//$res=mysql_query($sqlAceptar);
echo $sqlAceptar;
/*while($arre=mysql_fetch_array($res))
{
$m='MargenP'.$arre[id];
$p='PrecioP'.$arre[id];
$sql2="UPDATE articulosLista SET margen='$_POST[$m]', precio='$_POST[$p]' Where id='$arre[id]'";
//$res2=mysql_query($sql2);
echo $sql2;
}*/
break;
}
?>
<form method="post" name="formListaProd" onkeypress="anulaenter()">
<h1>Lista de Productos</h1>
<input type="hidden" size="5" id="oculto" name="oculto" />
<table width="701" border="0">
<tr>
<td width="113"><select name="Lista" size="1" >
<option selected="<? echo $habCampoVacio ?>"></option>
<?
$sql="Select id,nombre From listas order by nombre";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res))
{ if($row[id]==$_POST['Lista'])
{?>
<option value="<? echo $row[id] ?>" <? echo $habOpciones ?>><? echo $row[nombre] ?></option>
<? }
else
{ ?>
<option value="<? echo $row[id] ?>" ><? echo $row[nombre] ?></option>
<? }
}?>
</select></td>
<td width="66"><input name="boton" class="btnGuardar1" type="submit" value="Ver Lista" /></td>
<td width="16"> </td>
<td width="220">
<div align="center">
<input type="text" id="CrearLista" name="CrearLista" size="15"/>
<input type="submit" name="boton" class="btnGuardar1" value="Crear Lista" onclick="return validanombreLista()"/>
</div></td>
<td width="264"><div align="right">
<select name="EliminarLista" id="EliminarLista" size="1" >
<option selected="<? echo $selected; ?>"></option>
<?
$sql="Select id,nombre From listas order by nombre";
$res=mysql_query($sql);
while($rowElimina=mysql_fetch_array($res))
{if($rowElimina[id]==$_POST['EliminarLista'])
{$selected=""; ?>
<option value="<? echo $rowElimina[id] ?>" selected><? echo $rowElimina[nombre] ?></option>
<? }
else
{ $selected=""; ?>
<option value="<? echo $rowElimina[id] ?>" ><? echo $rowElimina[nombre] ?></option>
<? }
}?>
</select>
<input name="button" type="button" class="btnGuardar1" value="Eliminar Lista" onclick="eliminarVentanaLista('<? echo $rowElimina[nombre] ?>')" />
</div></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><div id="name" style="display:none; color:red"> Nombre inválido*</div></td>
<td></td>
</tr>
</table>
<? if($band==true)
{ ?>
<table width="710px">
<thead>
<tr>
<th width="107" height="35">Codigo</th>
<th width="261">Descripcion</th>
<th width="59">Costo</th>
<th width="67">Margen</th>
<th width="48">Precio</th>
<th width="140"></th>
</tr>
</thead>
</table>
<div class="TablaListas" >
<table class="TablaCompra">
<tbody>
<?
while($rowComp=mysql_fetch_array($resulL))
{
$sql1="Select * From articulos Where id=$rowComp[idArt]";
$resultado=mysql_query($sql1);
$art=mysql_fetch_array($resultado);
?>
<tr >
<td class="td"><input type="text" name="CodigoP" value="<? echo $rowComp['idArt'] ?>" size="5" readonly /></td>
<td class="td"><input type="text" name="DescripcionP" size="50" value="<? echo $art['nombre'] ?>" readonly/></td>
<td class="td"><input type="text" id="costo<? echo $rowComp[id] ?>" name="CostoP" size="5" value="<? echo round($rowComp['costo'],2) ?>" readonly/></td>
<td class="td"><input type="text" id="margen<? echo $rowComp[id] ?>" name="MargenP<? echo $rowComp[id] ?>" size="5" value="<? echo number_format($rowComp['margen'],2,',','.') ?>" onChange="calcularprecio(<? echo $rowComp[id] ?>)" /></td>
<td class="td"><input type="text" id="precio<? echo $rowComp[id] ?>" name="PrecioP<? echo $rowComp[id] ?>" size="5" value="<? echo number_format($rowComp['precio'],2,',','.') ?>" readonly/></td>
<!--Botones Eliminar -->
<td width="10">
<div align="right">
<input name="boton" type="submit" class="imgEliminar" title="Eliminar" value="_" onclick="idoculto('<? echo $rowComp[id] ?>')" />
</div></td>
</tr>
<? } ?><!--end while-->
</tbody>
</table>
</div>
<? } //end if band ?>
<!-- Eliminar VEntana -->
<div id="miVentana15" style="position: fixed; width: 350px; height: auto; top: 0; left: 0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; border: #333333 3px solid; background-color: #FAFAFA; color: #000000; display:none;">
<div style="font-weight: bold; text-align: left; color: #FFFFFF; padding: 5px; background-color:#006394">¡ATENCION!</div>
<div id="prueba15" style=" text-align: center; margin-top: 44px;"><p style="padding: 5px; text-align: justify; line-height:normal"></p></div>
<div style="padding: 10px; background-color: #F0F0F0; text-align: center; margin-top: 54px;">
<input onclick="ocultarVentana15()" name="boton" class="btnEliminar" size="20" type="submit" value="Eliminar" />
<input onclick="ocultarVentana15()" class="btnVolver" size="20" type="submit" value="Cancelar" />
</div>
</div>
<br/>
<br/>
<table width="182">
<td width="87"><div align="center">
<input name="Volver" reset="reset" class="btnCancelar" value="Cancelar" type="submit"/>
</div></td>
<td width="95"><div align="center">
<input type="submit" name="boton" class="btnGuardar" value="Aceptar"/>
</div></td>
</table>
idLista:<input type="text" value="<? echo $_POST[Lista] ?>" />
</form>
</body>
</html>
|