Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/04/2011, 19:27
moscrates
 
Fecha de Ingreso: julio-2008
Mensajes: 366
Antigüedad: 15 años, 9 meses
Puntos: 7
Respuesta: Clonar Campos

no td5 es un row de un atabla
la funcion completa es esta solo que esta muy larga.
Código Javascript:
Ver original
  1. var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
  2.     var row = document.createElement("TR");
  3.     var td1 = document.createElement("TD");
  4.     td1.appendChild(document.createElement("<input type=\"text\" id=\"animal["+t+"]\" name=\"animal["+t+"]\"size=\"25\"/>"));
  5.     var td2 = document.createElement("TD");
  6.     td2.appendChild (document.createElement("<input type=\"text\" name=\"precio["+t+"]\" id="+t+" />"));
  7.     var td3 = document.createElement("TD");
  8.     td3.appendChild (document.createElement("<select name=\"tipo_pago["+t+"]\" id="+t+" onChange=\"activar(this)\" >"));
  9.     var td4 = document.createElement("TD");
  10.     td4.appendChild (document.createElement(" <select name=\"tarjeta["+t+"]\" style=\"display:none;\" id="+t+"> "));
  11.    
  12.    
  13.     var option = document.createElement("<option value=\"N/A\"></option>");
  14.     var option2 = document.createElement("<option value=\"Efectivo\"></option>");
  15.     var option3 = document.createElement("<option value=\"Tarjeta\"></option>");
  16.    
  17.    
  18.     var texto1 = document.createTextNode("- - - - - - ");
  19.     var texto2 = document.createTextNode("Efectivo");
  20.     var texto3 = document.createTextNode("Tarjeta");
  21.    
  22.    
  23.     option.appendChild(texto1);
  24.     td3.appendChild(option);
  25.  
  26.     option2.appendChild(texto2);
  27.     td3.appendChild(option2);
  28.  
  29.     option3.appendChild(texto3);
  30.     td3.appendChild(option3);
  31.    
  32.     var option4 = document.createElement("<option value=\"N/A\"></option>");
  33.     var option5 = document.createElement("<option value=\"Banamex\"></option>");
  34.     var option6 = document.createElement("<option value=\"Scotiabank\"></option>");
  35.    
  36.    
  37.     var texto4 = document.createTextNode("- - - - - - ");
  38.     var texto5 = document.createTextNode("Banamex");
  39.     var texto6 = document.createTextNode("Scotiabank");
  40.    
  41.    
  42.     option.appendChild(texto1);
  43.     td3.appendChild(option);
  44.  
  45.     option2.appendChild(texto2);
  46.     td3.appendChild(option2);
  47.  
  48.     option3.appendChild(texto3);
  49.     td3.appendChild(option3);
  50.    
  51.     option4.appendChild(texto4);
  52.     td4.appendChild(option4);
  53.  
  54.     option5.appendChild(texto5);
  55.     td4.appendChild(option5);
  56.  
  57.     option6.appendChild(texto6);
  58.     td4.appendChild(option6);
  59.    
  60.     //var asesor= document.getElementById("asesor").cloneNode(true);
  61.     //td5.appendChild(asesor);
  62.    
  63.     var que = document.getElementById('producto');
  64.     var nuevo = que.cloneNode(true);
  65.     //que.parentNode.appendChild(nuevo);
  66.     td6.appendChild(nuevo);
  67.    
  68.     row.appendChild(td1);
  69.     row.appendChild(td6);
  70.     row.appendChild(td2);
  71.     row.appendChild(td3);
  72.     row.appendChild(td4);
  73.     //row.appendChild(td5);
  74.    
  75.     tbody.appendChild(row);