Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/06/2010, 01:09
gspablo
 
Fecha de Ingreso: octubre-2009
Mensajes: 223
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: Crear nuevo campo en formulario

Tambien he probado esto pero no se como hacer esto para que salga de la misma forma que la tabla creada, yo creo una linea de tabla y luego 2 celdas, una con el titulo y otra con el campo, con esto solo consigo crear un campo debajo de otro y nada de titulo

Código HTML:
Ver original
  1. <tr>
  2. <td align="center"><p> ATTACHMENT &nbsp;</p></td>
  3. <td> <input name="nattachment[]" id="idattachment" type="text" alt="User" size="100" maxlength="90"/></td>
  4. </tr>
  5.  
  6. <tr>
  7. <td colspan="2" align="center">
  8. <div id="inputText">
  9. <input value="New attachment" onclick="creaCampo2();"  type="button">
  10. </div>
  11. </td>
  12. </tr>
  13.  
  14. <tr>
  15. <td colspan="2"  align="center"> <input name="send" id="idsend" type="submit" alt="Send" value='CREATE' /> </td>
  16. </tr>
Código Javascript:
Ver original
  1. function nuevoCampoForm(type,name,id,value,size){
  2.         var campoForm=document.createElement("input");        
  3.           campoForm.setAttribute("value",value);
  4.             size==undefined?32:size;
  5.             campoForm.setAttribute("type","text");
  6.             campoForm.setAttribute("size",100);
  7.             campoForm.setAttribute("maxlenght",90);
  8.            
  9.     campoForm.setAttribute("name",name);
  10.     campoForm.setAttribute("id",id);
  11.     return campoForm;
  12. }
  13. function creaCampo2(){
  14.     var div2=document.getElementById("inputText");
  15.     var txt=new nuevoCampoForm('text','nattachment[]','idattachment','','32');
  16.     var txt2=new nuevoCampoTd();
  17.      div2.appendChild(txt);
  18.      div2.appendChild(txt2);
  19.  
  20. }