Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/07/2006, 18:59
Avatar de B**
B**
 
Fecha de Ingreso: enero-2006
Ubicación: Monterrey,Mexico
Mensajes: 952
Antigüedad: 18 años, 3 meses
Puntos: 3
Yo mando llamar a la funcion addcampo (q esta mas abajo) para q me agregue un input de tipo "File" para agregar archivos adjuntos en un formulario de correo, pero cambia las cosas q no te sirvan y lo adaptas a lo q necesitas, de todos modos si quieres ejemplos mas claros busca en el foro, ya se ha tratado el tema.

Código PHP:
<script type="text/javascript">
var 
numero 0;

// Funciones comunes
creatag= function (tag) { // Crea un elemento
   
return document.createElement(tag);
}
elementodiv = function (id) { // Retorna un elemento en base al id
   
return document.getElementById(id);
}
evento = function (evt) { // Retorna el evento
   
return (!evt) ? event evt;
}
objevento = function (evt) { // Retorna el objeto que genera el evento
   
return evt.srcElement ?  evt.srcElement evt.target;
}

addcampo = function () {
   
contenedor elementodiv('files');

   
span creatag('SPAN');
   
span.className 'file';
   
span.id 'file' + (++numero);

   
campo creatag('INPUT');
   
campo.name 'archivos[]';
   
campo.type 'file';

   
creatag('a');
   
a.name span.id;
   
a.href '#';
   
a.onclick quitacampo;
   
a.innerHTML 'Quitar';

   
span.appendChild(campo);
   
span.appendChild(a);
   
contenedor.appendChild(span);
}
quitacampo = function (evt) {
   
lnk objevento(evento(evt));
   
span elementodiv(lnk.name);
   
span.parentNode.removeChild(span);
}
 

</script> 
Espero te sirva.. saludos
__________________
-URL= Go PHP5.
-Age=22.
-Learning=PHP,J2EE,Struts,MAMBO,C++,JSON,AJAX,XHTML ,CSS.