Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/11/2009, 15:26
rfonseca
 
Fecha de Ingreso: noviembre-2009
Mensajes: 13
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Problema con editar una fila con Jquery!!!!

bueno lo he tratado de hacer como dijo hector2c..lo que tengo es esto!!!..."miembros.php"

Código PHP:
<table id="tabla" class="miembros">
                <thead>
                        <tr>
                            <th colspan="2"><img src="delete.png" /> Elimina Integrantes</th>
                            <th colspan="2"><img src="editar1.gif" /> Edita Integrantes</th>
                        </tr>
                </thead>
                <thead>
                    <tr>
                        <th>Nombre</th>
                        <th>Apellido Paterno</th>
                        <th>Apellido Materno</th>
                    </tr>
               </thead>
               <tbody>
                        <?php
                                
include("conexion.php");
    
                                
$con_miembro "select *from miembros;"
                                
$miembros mysql_query($con_miembro,$conect);
                                
                                while(
$row mysql_fetch_array($miembros))
                                {
                                        echo 
"<tr>";
                                        echo 
"<td style='display:none' id='miembro'>".$row['id_miembro']."</td>";
                                        echo 
"<td>".$row['nom_miembro']."</td>";
                                        echo 
"<td>".$row['apellido_pat']."</td>";
                                        echo 
"<td>".$row['apellido_mat']."</td>";
                                        echo 
" <td><a class='elimina'><img src='delete.png'/></a></td>";
                                        echo 
" <td><a class='edita'><img src='editar1.gif'/></a></td>";
                                        echo 
"</tr>";
                                }                        
                        
?>
                </tbody>
            </table>
y desde este archivo llamo a miembros.js donde eliminar lo hace bien...

$("a.elimina").click(function(){
id = $(this).parents("tr").find("td").eq(0).html();
nom = $(this).parents("tr").find("td").eq(1).html();
pat = $(this).parents("tr").find("td").eq(2).html();
mat = $(this).parents("tr").find("td").eq(3).html();
eliminar = confirm("Desea eliminar el usuario: " /*+ id + " "*/ + nom + " " + pat + " " + mat );
if (eliminar){
$(this).parents("tr").fadeOut("normal", function(){
$(this).remove();
alert("El usuario: " + nom + " " + pat + " " + mat + " fue eliminado");

$.post("elimina_miembro.php", {id_miembro: id})


})
}
});
};
hasta aqui todo bien!!!!!....ahora lo que llevo de editar que es mi problema!!

function editar(){

$("a.edita").click( function(){

//var valor = $(this).attr("value");
//var valor = $(this).parents("tr").find("td").eq(0).html();
id = $(this).parents("tr").find("td").eq(0).html();
nombre = $(this).parents("tr").find("td").eq(1).html();
paterno = $(this).parents("tr").find("td").eq(2).html();
materno = $(this).parents("tr").find("td").eq(3).html();
alert(" "+ id + " " + nombre + " " + paterno + " " + materno);
$.post("editar_miembro.php",
{ nombre: nom, paterno: pat, materno:mat },
function(data){
//alert(id);
$("#id").show().html(data);
}
);
return false;
});
};

que lo que hago es obtener el id del integrante... y lo que quiero es que en el php en click al editar este me muestre el nombre, apellido_1,apellido_2....y con el id de ese integrante poder hace un UPDATE para modificar el nombre con los apellidos...