Por ejemplo si tengo esta lista:
1------jose -------- 1234------boton borrar
2------juan -------- 456-----boton borrar
3-----pepe ----------4567----boton borrar
La funcion js de borrar solo me la hace en la primera fila y en las demas me manda el form pero no elimina la fila que pincho.
Este es el form
Código PHP:
Ver original
<?php do { ?> <tr> <td><input name="button" type=button /></td> <td><input name="button" type=button /></td> <td><input name="almacen1" class="modificar" disabled="disabled" type="text" size="2" value="<?php echo $row_Recordset1['almacen']; ?>" /></td> <td><input name="recambio1" class="modificar" disabled="disabled" id="recambio1" type="text" size="10" value="<?php echo $row_Recordset1['recambio']; ?>"/></td> <td><input name="denominacion1" class="modificar" disabled="disabled" type="text" size="25" value="<?php echo $row_Recordset1['denominacion']; ?>"/></td> <td><input name="cantidad1" class="modificar" disabled="disabled" type="text" size="5" value="<?php echo $row_Recordset1['cantidad']; ?>" /></td> <td><input name="pvp1" class="modificar" type="text" size="5" disabled="disabled" value="<?php $pvp1 = $row_Recordset1['pvp']; <td><input name="descuento1" class="modificar" type="text" size="5" disabled="disabled" value="<?php echo $row_Recordset1['descuento']; ?>" /></td> <td><input name="pvp_total1" class="modificar" type="text" size="5" disabled="disabled" value="<?php $pvp_total1 = $row_Recordset1['pvp_total']; </td> <form method="POST" name="form5" id="form5" action="<?php echo $editFormAction; ?>"> <td><input type="image" src="imagenes_menu/cancelar.png" width="20" height="20" style="cursor:pointer" /></td> <input type="hidden" name="id_aviso" value="<?php echo $row_Recordset1['id_aviso']; ?>" size="32" /> <input type="hidden" name="id_fact" value="<?php echo $row_Recordset1['id_fact']; ?>" size="32" /> <input type="hidden" name="recambio1" value="<?php echo $row_Recordset1['recambio']; ?>" size="32" /> <input type="hidden" name="cantidad1" value="<?php echo $row_Recordset1['cantidad']; ?>" size="32" /> <input type="hidden" name="MM_delete" value="form5" /> </form> </tr>
js
Código Javascript:
Ver original
$(document).ready(function() { $('#form5').submit(function(event) { var datos = $(this).serialize(); event.preventDefault() $.ajax( { url:'del_avisos.php', type:'POST', data:datos, beforeSend:function(objeto){ $('#carga').css({display:'block'}); }, complete:function(){ $('#carga').css('display','none'); }, success: function(data) { $('#result').html(data); window.location.href="ver_avisos_web.php"; } }); }); });
php
Código PHP:
Ver original
$deleteSQL = sprintf("DELETE FROM detalle_factura_mc WHERE recambio='".$_POST['recambio1']."' AND id_aviso='".$_POST['id_aviso']."' ", GetSQLValueString($_GET['id_aviso'], "int"), GetSQLValueString($_GET['recambio'], "int"));
Gracias y un saludo