Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/02/2011, 05:56
midgardo2002
 
Fecha de Ingreso: enero-2010
Mensajes: 11
Antigüedad: 15 años, 2 meses
Puntos: 0
php y javascript error al actualizar la bd con window.confirm

hola buen dia a todos, alguien puede ayudarme y revisar mi codigo estoy haciendo un formulario para cancelar unos cheques, tengo algo mal porque cuando consulto el numero de cheque a cancelar me lo cancela antes de oprimir el boton de cancelar cheque y ademas no me manda el mensaje de cuando se cancela el cheque, tendria que esperar el formulario a que el usuario oprimiera el boton cancelar cheque y esperar la confirmacion para poder actualizar la bd y mandar el mensaje de que el cheque ya fue cancelado.


saludos y gracias a todos

Código:
<?php
$nomb=$come;

$hora= time();
$fech=date("d/m/Y");
include ("conexion.php");
include ("caja_scripts.php");


if($_POST[cheque])
{
	$cancelacheque=mysql_query("select caja_pagado.numsocio, caja_pagado.total, caja_pagado.numcheque, socios.numsocio, socios.nomreal, socios.rfcsocio from caja_pagado inner join socios on caja_pagado.numsocio=socios.numsocio where numcheque='$cheque' and estatus='pagado';");
	$row=mysql_fetch_array($cancelacheque);

	$numsocio1=$row[numsocio];
	$nombre1=$row[nomreal];
	$rfc1=$row[rfcsocio];
	$importe1=$row[total];

	$estatuscheque=mysql_query("select estatus from caja_pagado where numcheque='$cheque';");
	$resestatus=mysql_fetch_array($estatuscheque);
	$valorestatuscheque=$resestatus[estatus];
	if($valorestatuscheque=="CANCELADO")
	{
?>
		<script languaje='javascript'>
		alert("EL CHEQUE YA FUE CANCELADO");
		</script>
<?php	}
}
echo "<script languaje='javascript'>";

echo	"function actualizar(form)";
echo	"{";
		if ("window.confirm")
		{
			$queryupdate=mysql_query("update caja_pagado set estatus='CANCELADO' where numcheque='$cheque';");
				if($queryupdate)
				{
?>
		<script languaje='javascript'>
		alert("EL CHEQUE HA SIDO CANCELADO");
		</script>

<?php
				}
		}
echo	"}";
echo "</script>";
if(($nomb)!="")
{
echo "<font color=#00FF00><h6>HOLA $nomb</h6></font>";

echo "<font color=#00FF00><h6>AREA DE $ar</h6></font>";
?>
<html>
<head>
	<?php echo "<title> &nbsp; $ar</title>";
	echo "<center><b><font color=lime><font size=5>$ar (CANCELACIONES DE CHEQUES)</font></center>";
	?>
</head>
<br>
<body bgcolor='black' onLoad="this.document.forma_caja.cheque.focus();">
<form name='forma_caja' id='forma_caja' action="" method="POST">
<table border=1 cellpadding=0 cellspacing=0>
<tr>
	<td colspan=1 width=25%><font color="#00FF00">
		<?php echo "<input type=hidden name=come value='$nomb' style=width:265px; height:30px ></center>"; ?>
		NUMERO DE CHEQUE&nbsp;&nbsp;
	</td>
	<td colspan=1 width=25%><font color="#00FF00">
		<input type=text name=cheque size=25 onKeyPress='return submitenter(this,event)' value="<?php echo $cheque ?>">
		</font></td>

	<td colspan=1 width=20%><font color="#00FF00">
		FECHA
	</td>
	<td colspan=1 width=25%><font color="#00FF00">
		<?php echo "<input type=text name=fecha size=25 readonly=readonly value=$fech>"; ?>
	</td>
	<td>
	<!--	<center><input type=button name=caprad value=NUEVO style=width:300px; height:30px onclick="captura()"></center> -->
	<center><input type=button style=width:300px; height:30px value=MENU onclick="regresa()"></center>
	</td>
</tr>

<tr>
	<td width=20%>
	</td>
	<td>
	</td>
	<td>
	</td>
	<td>
	</td>

	<td>
		<center><input type=button value='CONSULTA' onclick="consulta()" style=width:300px; height:30px></center>
	</td>
</tr>

<tr>
	<td>
	</td>
	<td>
	</td>
	<td>
	</td>
	<td>
	</td>

	<td width=35%>
		<center><input type=submit value='CANCELAR CHEQUE' name=guard style=width:300px; height:30px onclick="if(forma_caja.cheque.value!=''){if(ok=window.confirm('EL CHEQUE SE CANCELARA, DE ACUERDO?')){actualizar()}}else{alert('DEBES INTRODUCIR UN NUMERO DE CHEQUE')}" ></center>
	</td>

</tr>

</table>



<table border=1>


<tr>
	<td><font color=lime><center><b>
		NUMERO DE SOCIO</center>
	</td>
	<td><font color=lime><center><b>
		NOMBRE REAL DEL SOCIO</center>
	</td>
	<td colspan=1><font color=lime><center><b>
		RCF DEL SOCIO</center>
	</td>
	<td colspan=1><font color=lime><center><b>
		IMPORTE</center>
	</td>

</tr>
<tr>
	<td>

		<input type="text" maxlength=10 size=33 name=numsocio01 readonly=readonly value="<?php echo $numsocio1 ?>">
	</td>
	<td>
		<input type=text maxlength=100 size=75 name=nomreal01 readonly=readonly value="<?php echo $nombre1 ?>">
	</td>
	<td colspan=1>
		<input type=text maxlength=10 size=30 name=rfc01 readonly=readonly value="<?php echo $rfc1?>">
	</td>
	<td colspan=1>
		<input type=text maxlength=10 size=30 name=importe01 readonly=readonly value="<?php echo $importe1?>">
	</td>
</tr>

<tr>
	<td colspan=2><font color=lime><center><b>
		 </center>
	</td>

	<td><font color=lime><center><b>
		TOTAL </center>
	</td>
	<td><center>
		<input type=text maxlength=10 size=30 name=total01 readonly=readonly value="<?php echo $importe1?>">
	</td>

</tr>
<tr>
	<td colspan=3>

	</td>
</tr>

</table>
</form>

</body>
</html>
<?php

}

?>