este es el codigo javacsript con el q envio el form:
Código HTML:
<script> function enter(evt) { var charCode = (evt.which) ? evt.which : window.event.keyCode; if (charCode == 13) { document.form1.submit(); } } </script>
Código HTML:
<script LANGUAGE="JavaScript"> <!-- var cuenta=0; function enviado() { if (cuenta == 0) { cuenta++; return true; } else { alert("El formulario ya está siendo enviado, por favor aguarde un instante."); return false; } } // --> </script> <form name="form1" id="form1" action="nueva_instalacion.php?id=<? echo $_GET["id"]; ?>" method="post" onSubmit="return enviado()">
Código PHP:
if ( ! empty($_POST))
{
if( $_POST["fecha"] != "" && $_POST["cliente"] != "" && $_POST["marca"] != "" && $_POST["modelo"] != "" && $_POST["cubiculo"] != "" && $_POST["serie_i"] != "" && $_POST["prueba"])
{
$sql = "select interno,estado from cubiculos_gascon where numero = '".$_POST["cubiculo"]."'";
$resultado = mysql_query($sql);
while($fila = mysql_fetch_array($resultado))
{
$interno = $fila["interno"];
$estado = $fila["estado"];
?>
<script>
alert('<? echo $estado; ?>');
</script>
<?
}
if ($interno == "0" && $estado == "0")
{
$sql = "select estado from cubiculos_gascon where numero = '".$_POST["cubiculo"]."'";
$resultado = mysql_query($sql);
while ($row = mysql_fetch_array($resultado))
{
$estadoCub = $row["estado"];
}
if($estadoCub == 0)
{
$serie_impresora = $_POST["serie_i"];
$serie_sistema = $_POST["serie_s"];
$cubiculo = $_POST["cubiculo"];
$prueba = $_POST["prueba"];
if($prueba == "incorrecto")
{
$razon = $_POST["falla"];
if($razon == "impresion")
{
for($i = 0;$i <= 6;$i++)
{
if(isset($_POST["color".$i]))
{
$colores .= $_POST["color".$i].",";
}
}
}
}
if(isset($_POST["ch_cubiculo"]))
{
$update = "update instalaciones set serie_impresora = '$serie_impresora', serie_sistema = '$serie_sistema',cubiculo = '$cubiculo', razon = '$razon', prueba = '$prueba', colores = '$colores', estado = '".$_POST["instalacion"]."', operador = '$_SESSION[registrado]' where id_instalacion = '".$_GET["id"]."'";
$update_cubiculo = "update cubiculos_gascon set estado = '1' where numero = '$cubiculo'";
//$actualizar = mysql_query($update_cubiculo);
}else
{
$update = "update instalaciones set serie_impresora = '$serie_impresora', serie_sistema = '$serie_sistema',razon = '$razon', prueba = '$prueba', colores = '$colores', estado = '".$_POST["instalacion"]."', operador = '$_SESSION[registrado]' where id_instalacion = '".$_GET["id"]."'";
}
$actualizar = mysql_query($update);
if($_POST["instalacion"] == '2' || isset($_POST["ch_cubiculo"]))
{
echo "
<script>
window.resizeTo(800,730);
location.href='orden.php?id=".$_GET["id"]."';
</script>
";
die();
}else
{
echo "
<script>
window.close();
</script>
";
}
}
else
{
echo "<font color = 'red'>El cubiculo no esta disponible</font>";
}
}else
{
if($interno == '1')
{
echo "<script>
alert('el cubiculo es interno de la empresa');
</script>";
}else
{
echo "<script>
alert('el cubiculo esta ocupado ');
</script>";
}
}
}
}
muchas gracias
juan manuel