
Código Javascript :
i=0; //AÑADIR CAMPO function new_input(){ fila = new Array(); var campo1 = document.createElement("input"); var campo2 = document.createElement("input"); var campo3 = document.createElement("input"); var drop = document.createElement("select"); var sd1 = document.createElement("option"); var sd2 = document.createElement("option"); var sd3 = document.createElement("option"); var sd4 = document.createElement("option"); fila[i] = document.createElement("tr"); var col1 = document.createElement('td'); var col2 = document.createElement('td'); var col3 = document.createElement('td'); var col4 = document.createElement('td'); var linc = document.createElement('a'); linc.setAttribute("id","lnk"); drop.setAttribute("name","unidad[]"); sd1.setAttribute("value", "KG"); sd2.setAttribute("value", "GR"); sd3.setAttribute("value", "L"); sd4.setAttribute("value", "ML"); campo1.setAttribute("name", "nnombre[]"); campo2.setAttribute("name", "nprecio[]") campo3.setAttribute("name", "npres[]") campo1.setAttribute("maxlenght", "30"); campo1.setAttribute("size", "12"); campo2.setAttribute("maxlenght", "7"); campo2.setAttribute("size", "7"); campo3.setAttribute("maxlenght", "7"); campo3.setAttribute("size", "7"); document.getElementById("teibol").appendChild(fila[i]); fila[i].appendChild(col1); fila[i].appendChild(col2); fila[i].appendChild(col3); fila[i].appendChild(col4); drop.appendChild(sd1); drop.appendChild(sd2); drop.appendChild(sd3); drop.appendChild(sd4); sd1.appendChild(document.createTextNode("KG")); sd2.appendChild(document.createTextNode("GR")); sd3.appendChild(document.createTextNode("L")); sd4.appendChild(document.createTextNode("ML")); col1.appendChild(campo1); col2.appendChild(campo2); col3.appendChild(campo3); col3.appendChild(drop); col4.appendChild(linc); linc.setAttribute("href","javascript:remove("+i+")") linc.appendChild(document.createTextNode("Borrar")) i++; } //DELETEAR function remove(s){ document.getElementById("teibol").removeChild(fila[s]); }
Puedo crear correctamente...pero no borrarT_T lo que intento es borrar completamente el TR, pero solo borra el ultimo appendchild, espero puedan ayudarme, gracias de antemano.