Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/07/2008, 10:12
adiazq
 
Fecha de Ingreso: julio-2008
Mensajes: 96
Antigüedad: 15 años, 10 meses
Puntos: 0
Insertar valores de campos ocultos en PHP

Hola Muy buenos dias,
Compañeros este pagina me ha resultado super buenisima, porq me ha resuelto muchas dudas, pero esta vez me he encontrado con un obstaculo en mi proyecto: INSERTAR VALORES DE CAMPOS OCULTOS.
La descripcion de mi problema es el siguiente:

Tengo una tabla de 4 x 4 con unos datos. Estos datos los guardo en los campos ocultos durante el recorrido que le hago a la tabla. La idea es que al hacer el recorrido no lo inserte en los campos ocultos sino directamente en la base de datos. He probado con XAJAX que es una una clase realizada con PHP que nos permite utilizar Ajax, combinado con PHP, para la creación de aplicaciones interactivas, de una manera muy simplificada, pero no me ha dado resultados. Por favor si alguien ha realizado algun codigo parecido, les agradecere mucho su ayuda, ya que llevo 1 semana y no encuentro la solucion, de ajax no se mucho ya que apenas estoy conociendo la herramienta. DE ANTEMANO LE AGRADEZCO SU AYUDA

Código:
<script> function recorrer() { 
var textos = 'CONTENIDO_TABLA|'; 

for (var i=0;i<document.getElementById('TablaDatos').rows.length;i++)
{ 
	for (var j=0;j<4;j++) //RECORRE LAS COLUMNAS
	{ 
	textos = textos + document.getElementById('TablaDatos').rows[i].cells[j].innerHTML +'|';
	if (j==0)
	{
		 document.getElementById('hiddenField').value=document.getElementById('TablaDatos').rows[i].cells[j].innerHTML;
	}
	else
	{
	   if (j==1)
		{
			 document.getElementById('hiddenField2').value=document.getElementById('TablaDatos').rows[i].cells[j].innerHTML;
		}
		else
		{
		   if (j==2)
			{
				 document.getElementById('hiddenField3').value=document.getElementById('TablaDatos').rows[i].cells[j].innerHTML;
			}
			else
			{
			  if (j==3)
				{
					 document.getElementById('hiddenField4').value=document.getElementById('TablaDatos').rows[i].cells[j].innerHTML;
				}
			}
		}
	}
	}
alert (document.getElementById('hiddenField').value+" "+document.getElementById('hiddenField2').value+" "+document.getElementById('hiddenField3').value+" "+document.getElementById('hiddenField4').value);

//AQUI DEBERIA INSERTAR LOS VALORES DE LOS CAMPOS OCULTOS EN LA BASE DE DATOS... :-(


}

}

</script>

<table class="TablaDatos" id="TablaDatos" border="1">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>
<tr>
<td>13</td>
<td>14</td>
<td>15</td>
<td>16</td>
</tr>
</table>
<form name="form1" method="post" action="">
  <input type="hidden" name="hiddenField" id="hiddenField">
  <input type="hidden" name="hiddenField2" id="hiddenField2">
  <input type="hidden" name="hiddenField3" id="hiddenField3">
  <input type="hidden" name="hiddenField4" id="hiddenField4">
  <input name="Bot&oacute;n" type="button" onclick="recorrer()" value="Insertar" />
</form>