Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/02/2014, 12:38
raulgranadosraul
 
Fecha de Ingreso: julio-2013
Mensajes: 174
Antigüedad: 10 años, 9 meses
Puntos: 1
Problema con una ventana modal de varias que tengo en la pagina

Hola a todos, amigos del web.

Llevo rompiéndome la cabeza unos cuantos días y no logro saber que es lo que le ocurre a mi código. Les cuento.

Tengo una pagina en la que muestro las citas de los clientes de BD. En algunos campos tengo ventanas modales con un form para cambiar e insertar datos sin cambiar de ventana.

El caso es que tengo 4 forms en ventanas modales. 3 me hacen correctamente y de perlas el insert o el update. El problema es que intento hacer uno más, como mínimo, y no me hace el update. Lo curioso es que los otros 3 form van bien y el cuarto aunque haga un copia pega de alguno de los anteriores..... no hace nada.

Les paso el código por si me pueden echar una mano.

Query de modal 3:
Código PHP:
Ver original
  1. $editFormAction = $_SERVER['PHP_SELF'];
  2. if (isset($_SERVER['QUERY_STRING'])) {
  3.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  4. }
  5.  
  6. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form8")) {
  7.   $updateSQL = sprintf("UPDATE Citas_tbl SET txtComentario=%s WHERE idCita=%s",
  8.                        GetSQLValueString(nl2br($_POST['txtComentario']), "text"),
  9.                        GetSQLValueString($_POST['idCita'], "int"));
  10.  
  11.   mysql_select_db($database_opencel, $opencel);
  12.   $Result1 = mysql_query($updateSQL, $opencel) or die(mysql_error());
  13.  
  14.   $updateGoTo = "";
  15.   if (isset($_SERVER['QUERY_STRING'])) {
  16.     $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  17.     $updateGoTo .= $_SERVER['QUERY_STRING'];
  18.   }
  19.   header(sprintf("Location: %s", $updateGoTo));
  20. }

Js de modal 3:
Código Javascript:
Ver original
  1. function mostrarVentana3(idCita)
  2.         {
  3.             var ventana3 = document.getElementById('miVentana3');
  4.             ventana3.style.marginTop = "100px";
  5.             ventana3.style.left = ((document.body.clientWidth-300) / 2) +  "px";
  6.             ventana3.style.display = 'block';
  7.             document.getElementById("idCita").value = idCita;
  8.         }
  9.         function cerrarVentana3()
  10.         {
  11.             var ventana3 = document.getElementById('miVentana3');
  12.             ventana3.style.display = 'none';
  13.         }


Que recibe el idCliente desde aqui:
Código HTML:
Ver original
  1. <span style="cursor:pointer" onclick="javascript:mostrarVentana3(<?php echo $row_CitasHoy['idCita']; ?>);"><?php echo $row_CitasHoy['txtComentario']; ?>.</span>

El form de la modal 3 es:
Código HTML:
<form action="<?php echo $editFormAction; ?>" method="post" name="form8" id="form8">
	<table width="100%">
		<tr valign="baseline">
			<td width="100%" nowrap="nowrap" align="left" valign="middle" style="padding-left:5px"><h6 style="color:#000"><em>Nuevo comentario</em></h6></td>
		</tr>
		<tr valign="baseline">
			<td width="100%" nowrap="nowrap" align="left" valign="middle">&nbsp;</td>
		</tr>
		<tr valign="baseline">
			<td width="100%" nowrap="nowrap" align="left" valign="middle">
				<textarea name="txtComentario" cols="25" rows="5" value="" class="button" style="cursor:text;resize:none" autofocus="autofocus"></textarea>
			</td>
		</tr>
		<tr valign="baseline">
			<td width="100%" nowrap="nowrap" align="left" valign="middle">&nbsp;</td>
		<tr valign="baseline">
			<td width="100%" nowrap="nowrap" align="right" valign="middle">
                <input type="submit" value="Guardar" style="cursor:pointer" class="button" />
                <input type="button" value="Cerrar" onclick="javascript:cerrarVentana3();" style="cursor:pointer" class="button" />
            </td>
		</tr>
        <input type="hidden" id = "idCita" name = "idCita" />
        <input type="hidden" name="MM_update" value="form8" />
	</table>
</form> 
Esta modal hace el UPDATE perfecto. Donde no encuentro el por qué ni el problema es en el 4.

Query de modal 4:
Código PHP:
$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}


if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form7")) {
  
$updateSQL sprintf("UPDATE Citas_tbl SET txtAcciones=%s WHERE idCita=%s",
                       
GetSQLValueString($_POST['Acciones'], "text"),
                       
GetSQLValueString($_POST['idCita'], "int"));

  
mysql_select_db($database_opencel$opencel);
  
$Result1 mysql_query($updateSQL$opencel) or die(mysql_error());

  
$updateGoTo "";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
    
$updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$updateGoTo));

Js de modal 4:
Código Javascript:
Ver original
  1. function mostrarVentana4(idCita)
  2.         {
  3.             var ventana4 = document.getElementById('miVentana4');
  4.             ventana4.style.marginTop = "100px";
  5.             ventana4.style.left = ((document.body.clientWidth-300) / 2) +  "px";
  6.             ventana4.style.display = 'block';
  7.             document.getElementById("idCita").value = idCita;
  8.         }
  9.         function cerrarVentana4()
  10.         {
  11.             var ventana4 = document.getElementById('miVentana4');
  12.             ventana4.style.display = 'none';
  13.         }

Que recibe el parámetro de esta línea:
Código HTML:
<span style="cursor:pointer" onclick="javascript:mostrarVentana4(<?php echo $row_CitasHoy['idCita']; ?>);"><?php echo $row_CitasHoy['txtAcciones']; ?>.</span> 
El form de modal 4:
Código HTML:
<form action="<?php echo $editFormAction; ?>" method="post" name="form7" id="form7">
  <table align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Estado:</td>
      <td><input type="text" name="Acciones" value="<?php echo $row_CitasHoy['txtAcciones']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="Actualizar registro" /></td>
    </tr>
  <input type="hidden" name="idCita" id="idCita" />
  <input type="hidden" name="MM_update" value="form7" />
  </table>
</form> 
Siento extenderme tanto pero es que si os fijáis el código es el mismo, o yo lo veo así. La verdad es que aunque haga copia pega y le cambie los parámetros no corre el 4.

Sin embargo si hago todas las ejecuciones del 4 llamandolo 3.... me funciona correctamente, es decir que la programación está bien, creo...... pero al cambiar los parámetros para que me haga el 4..... sigue sin hacerlo. Muy raro la verdad.

¿Será un asunto de cantidad?
¿O realmente se me escapa algo en el código?
¿Alguna idea?

Gracias de antemano

Última edición por raulgranadosraul; 14/02/2014 a las 12:55 Razón: cambio de etiquetas