Tengo una pagina web que haciendo una consulta a la BD me hace unas tablas con unos formularios y en una parte hay 2 imagenes que me llaman una funcion en javascript que me valida y me modifica un campo.
El problema esta en que en el primer formulario si que me lo hace bien, pero en los otros solo me valida y no me carga las variables en el POST.
Pongo algo de codigo para que se vea mejor:
funcion javascript
Código:
<script type="text/javascript">
function envia(id,accion)
{
switch(accion)
{
case 'edit':
document.getElementById("accio").value='0';
document.getElementById("form"+id).submit();
break;
case 'del':
document.getElementById('accio').value='1';
document.getElementById('form'+id).submit();
break;
}
}
</script>
bucle que hace los formularos:
Código HTML:
while($fila=mysql_fetch_array($resultat))
{
echo "<form action='modnot.php' method='post' id='form".$i."'>";
echo "<table class='noticies'>";
?>
<tr>
<td height="7"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="principal">
<td height="24">
<input type='hidden' name="accio" value='' id="accio">
</td>
<th colspan="3" valign="top">
<input name="Titol<?php echo $i;?>" type="text" value="<?php echo $fila['Titol'];?>">
</th>
<td></td>
</tr>
<tr>
<td height="12"></td>
<td></td>
<td></td>
<td rowspan="3" valign="top">
<textarea id="area<?php echo $i;?>" name="area<?php echo $i;?>"><?php echo $fila['Contingut'];?></textarea>
</td>
<td></td>
</tr>
<tr>
<td height="199"> </td>
<td valign="top">
<img src="<?php echo $fila['Foto'];?>" width="100">
</td>
<td> </td>
<td> </td>
</tr>
<tr class="etapas">
<td height="19"></td>
<td>
<input type="hidden" name="num" value="<?php echo $i;?>">
<input name="link<?php echo $i;?>" size="10" type="text" value="<?php echo $fila['Link'];?>">
</td>
<td valign="top"></td>
<td colspan="2">
<div align="right">
<img src="../imatges/del.png" alt="eliminar" onClick="envia('<?php echo $i;?>','del')" />
<img src="../imatges/edit.png" alt="editar" onClick="envia('<?php echo $i;?>','edit')" />
</div>
</td>
</tr>
<?php
echo "</table></form>";
$i++;
}//fi while
y no se porque en el primer formulario me funciona y en los demas no.
El codigo que genera queda asi:
Código HTML:
<form action='modnot.php' method='post' id='form0'>
<table class='noticies'>
<tr>
<td height="7"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="principal">
<td height="24">
<input type='hidden' name="accio" value='' id="accio">
</td>
<th colspan="3" valign="top">
<input name="Titol0" type="text" value="NOTICIA DE PRUEBA">
</th>
<td></td>
</tr>
<tr>
<td height="12"></td>
<td></td>
<td></td>
<td rowspan="3" valign="top">
<textarea id="area0" name="area0"><strong>Texto de prueba</strong></textarea>
</td>
<td></td>
</tr>
<tr>
<td height="199"> </td>
<td valign="top">
<img src="Admin/img/logo/1213140677.jpeg" width="100">
</td>
<td> </td>
<td> </td>
</tr>
<tr class="etapas">
<td height="19"></td>
<td>
<input type="hidden" name="num" value="0">
<input name="link0" size="10" type="text" value="www.google.com">
</td>
<td valign="top"></td>
<td colspan="2">
<div align="right">
<img src="../imatges/del.png" alt="eliminar" onClick="envia('0','del')" />
<img src="../imatges/edit.png" alt="editar" onClick="envia('0','edit')" />
</div>
</td>
</tr>
</table>
</form>
<form action='modnot.php' method='post' id='form1'>
<table class='noticies'>
<tr>
<td height="7"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="principal">
<td height="24">
<input type='hidden' name="accio" value='' id="accio">
</td>
<th colspan="3" valign="top">
<input name="Titol1" type="text" value="Prueba 2">
</th>
<td></td>
</tr>
<tr>
<td height="12"></td>
<td></td>
<td></td>
<td rowspan="3" valign="top">
<textarea id="area1" name="area1">fffffffff</textarea>
</td>
<td></td>
</tr>
<tr>
<td height="199"> </td>
<td valign="top">
<img src="Admin/img/logo/1213186776.gif" width="100">
</td>
<td> </td>
<td> </td>
</tr>
<tr class="etapas">
<td height="19"></td>
<td>
<input type="hidden" name="num" value="1">
<input name="link1" size="10" type="text" value="www.guifi.net">
</td>
<td valign="top"></td>
<td colspan="2">
<div align="right">
<img src="../imatges/del.png" alt="eliminar" onClick="envia('1','del')" />
<img src="../imatges/edit.png" alt="editar" onClick="envia('1','edit')" />
</div>
</td>
</tr>
</table>
</form>
y asi los siguientes, bueno, si alguien puede ayudarme se lo agradecere