Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/07/2015, 14:46
Jokibu
 
Fecha de Ingreso: julio-2015
Mensajes: 7
Antigüedad: 8 años, 9 meses
Puntos: 0
funcion js para clonar tabla

Hola tengo un js que clona una tabla al pulsar un boton , en el mismo html y funciona , pero necessito tener diferentes tablas con la misma funcion, creo un fichero js con la funcion, pero al clonar m`he clona todas, o sea al preimer clonar, clona 1 pero al siguiente clona 2..., ya que estamos m`he aprovecho un poco, para recuperar la informacion de todas las tablas para guardar a la BD, tendria que indexar los imputs?

Muchas Gracias.

PD: el codigo es sacado de esta misma web pero de un tema de 2010.


<html>

<head>
<title>Pruebas</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(function(){

tabla = $('#tabla');
tr = $('tr:first', tabla);
$('#agregarFila').live('click', function (){
tr.clone().appendTo(tabla).find(':text').val('');
});

$(".eliminarFila").live('click', function (){
$(this).closest('tr').remove();
});

});
</script>
</head>
<body>
<table width="451" border="2" id="tabla">

<tr id="t1">
<td width="39" align="center"><label for="textfield"></label>
<input name="qtt1" type="text" id="qtt1" size="3" /></td>

<td width="205" align="center"><label for="select"></label>
<select name="desc1" id="desc1"></select></td>

<td width="57" align="center"><label for="textfield"></label>
<input type="text" name="al1" id="al1" size="5" /></td>

<td width="55" align="center"><input type="text" name="amp1" id="amp1"size="5" /></td>
<td width="88"><input type="button" value="Eliminar" class="eliminarFila"></td>
</tr>
</table>
<input type="button" value="Agregar" id="agregarFila">


</body>
</html>