Ver Mensaje Individual
  #11 (permalink)  
Antiguo 04/01/2008, 06:25
novatoRR
 
Fecha de Ingreso: enero-2008
Mensajes: 1
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Aumentar filas a una tabla html al dar click

Hola a todos,

Copie el codigo de _ssx y funcionaba bien, hasta que le meti mano para adaptarlo hi ahora no funciona en explorer, si en firefox. Soy principiante y no se ver donde esta el problema, seguramente es una tonteria, pero es lo que tiene el ser un principiante.

Muchas gracias por anticipado

Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript">
var upload_number=1;
function addFileInput() {
var i=0;
var tr = document.createElement("tr");
var td1 = document.createElement("td");
td1.setAttribute("width", "100");
td1.setAttribute("align", "center");

var file = document.createElement("input");
file.setAttribute("type", "text");
file.setAttribute("name", "fotografia[]");
file.setAttribute("id", "fotografia[]");
file.setAttribute("size", "12");
file.setAttribute("maxlength", "10");
td1.appendChild(file);

var td2 = document.createElement("td");
td2.setAttribute("width", "200");
td2.setAttribute("align", "center");

var file0 = document.createElement("select");
file0.setAttribute("name", "formato[]");
file0.options[i] = new Option('Digital 3000x2000','Digital 3000x2000');
i++;
file0.options[i] = new Option('Digital 800x533','Digital 800x533');
i++;
file0.options[i] = new Option('Papel 10x15','Papel 10x15');
i++;
file0.options[i] = new Option('Papel 15x22','Papel 15x22');
i++;
file0.options[i] = new Option('Papel 20x30','Papel 20x30');
i++;
file0.options[i] = new Option('Papel 30x40','Papel 30x40');
i++;
file0.options[i] = new Option('Papel 40x60','Papel 40x60');
td2.appendChild(file0);

var td3 = document.createElement("td");
td3.setAttribute("width", "40");
td3.setAttribute("align", "center");

var file2 = document.createElement("input");
file2.setAttribute("type", "text");
file2.setAttribute("name", "ud[]");
file2.setAttribute("id", "ud[]");
file2.setAttribute("size", "3");
file2.setAttribute("maxlength", "2");
td3.appendChild(file2);

tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
document.getElementById("moreUploads").appendChild(tr);
upload_number++;
}
</script>
<title>Pix MotoRR</title>
</head>

<body>
<div align="center"><input type="button" name="button" id="button" value="Crear otra fila" onclick="javascript:addFileInput()"/></div>
<a href="javascript:addFileInput()">Añadir fila</a>
<table border="1" align="center" cellpadding="1" cellspacing="1" id="moreUploads">
<tr>
<td width="100" heigth="100" align="center">N&ordm; Fotografia</td>
<td width="200" heigth="100" align="center">Formato</td>
<td width="40" heigth="100" align="center">Ud</td>
</tr>

<tr>
<td width="100" height="20" align="center"><input name="fotografia[]" type="text" id="fotografia[]" size="12" maxlength="10"/></td>

<td width="200" height="20" align="center"><select name="formato[]" id="formato[]">
<option value="Digital 3000x2000">Digital 3000x2000</option>
<option value="Digital 800x533">Digital 800x533</option>
<option value="Papel 10x15">Papel 10x15</option>
<option value="Papel 15x22">Papel 15x22</option>
<option value="Papel 20x30">Papel 20x30</option>
<option value="Papel 30x40">Papel 30x40</option>
<option value="Papel 40x60">Papel 40x60</option>
</select></td>

<td width="40" height="20" align="center"><input name="ud[]" type="text" id="ud[]" size="3" maxlength="2"/></td>
</tr>

</table>
</body>
</html>