Hi there,
I'm succesfully try this: 
http://groups.google.com/group/jquery-en/browse_thread/thread/8d85c32c459564fa
for copy the last class of a set of two classes in a last TR of an
HTML table. The reason that for I'm doing this is for implement
dinamically alternate bgcolor color in TR, the changes in my code
works succesfully in Firefox, but IE7/8 is the problem.

Here is my jQuery code:
<pre>
function duplicar_fila(table_name) {
        // First, lets create the new row using the last one as template...
        var cloned_row = $("#"+table_name+" tr:last").clone();

        // Copy the last class of set of two
        var bc_class = $("#"+table_name+" tr:last").attr('class').split('
').slice(-1);

        // Take the current identifier, some number in the first cell of the
row
        var curr_id = parseInt($("#correlativo:last", cloned_row).html());

        // Set the new ID
        new_id = curr_id + 1;

        // Change the current identifier of the row to the new one
        $("#correlativo:last", cloned_row).html(new_id);

        // Change the Id / Name or anything you want for the new attribs
        $("#campo_id"+curr_id, cloned_row).attr( {
                        id : "campo_id"+new_id,
                        name : "campo_id["+new_id+"]",
                        value : "N"
                }
        );
        $("#tipo_campo"+curr_id, cloned_row).attr( {
                        id : "tipo_campo"+new_id,
                        name : "tipo_campo["+new_id+"]",
                        value : "0"
                }
        );
        $("#etiqueta"+curr_id, cloned_row).attr( {
                        id : "etiqueta"+new_id,
                        name : "etiqueta["+new_id+"]",
                        value : ""
                }
        );
        $("#longitud_max"+curr_id, cloned_row).attr( {
                        id : "longitud_max"+new_id,
                        name : "longitud_max["+new_id+"]",
                        value : ""
                }
        );
        $("#filas_o_altura"+curr_id, cloned_row).attr( {
                        id : "filas_o_altura"+new_id,
                        name : "filas_o_altura["+new_id+"]",
                        value : ""
                }
        );
        $("#opciones"+curr_id, cloned_row).attr( {
                        id : "opciones"+new_id,
                        name : "opciones["+new_id+"]",
                        value : ""
                }
        );

        $("#delete_link"+curr_id, cloned_row).attr( {
                        id : "delete_link"+new_id,
                        title : "Quitar fila "+new_id,
                        onclick : "eliminar_fila('"+table_name 
+"','"+new_id+"')"
                }
        );

        // Add to the new row to the original table
        $("#"+table_name+"").append(cloned_row);

        // And finally change the ID of the last row, and alternate the Class
    $("#"+table_name+" tr:last").attr( {
                        id : "bc"+new_id,
                        class : "bc "+(bc_class=='trBgColor1' ? 'trBgColor2' :
'trBgColor1')
                }
        );
}
</pre>

I hope you understand my problem and can help me.
Thank you!.

Reply via email to