Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/01/2010, 13:25
poitofritoxd
 
Fecha de Ingreso: abril-2008
Mensajes: 21
Antigüedad: 16 años, 1 mes
Puntos: 0
Ayuda con codigo Javascript


Hola!
Me baje un código javascript de internet y quisiera hacerle una pequeña modificación para lograr lo que quiero, es el siguiente:

Código Javascript:
Ver original
  1. function MultiSelector( list_target, max ){
  2.     this.list_target = list_target;
  3.     this.count = 0;this.id = 0;
  4.     if( max ){
  5.         this.max = max;
  6.     } else {
  7.         this.max = -1;
  8.     }
  9.     ;this.addElement = function( element ){
  10.         if( element.tagName == 'INPUT' && element.type == 'file' ){
  11.             element.name = 'file_' + this.id++;element.multi_selector = this;element.onchange = function()
  12.             {var new_element = document.createElement( 'input' );
  13.             new_element.type = 'file';this.parentNode.insertBefore( new_element, this );
  14.             this.multi_selector.addElement( new_element );
  15.             this.multi_selector.addListRow( this );
  16.             this.style.position = 'absolute';
  17.             this.style.left = '-1000px';};
  18.             if( this.max != -1 && this.count >= this.max ){
  19.                 element.disabled = true;
  20.                 };
  21.                 this.count++;
  22.                 this.current_element = element;
  23.         } else {
  24.             alert( 'Error: not a file input element' );
  25.         };
  26.     };this.addListRow = function( element ){
  27.         var new_row = document.createElement( 'div' );
  28.         var new_row_button = document.createElement( 'input' );
  29.         new_row_button.type = 'button';
  30.         new_row_button.value = 'Delete';
  31.         new_row.element = element;
  32.         new_row_button.onclick= function(){
  33.             this.parentNode.element.parentNode.removeChild( this.parentNode.element );
  34.             this.parentNode.parentNode.removeChild( this.parentNode );
  35.             this.parentNode.element.multi_selector.count--;
  36.             this.parentNode.element.multi_selector.current_element.disabled = false;
  37.             return false;};new_row.innerHTML = element.value;
  38.             new_row.appendChild( new_row_button );
  39.             this.list_target.appendChild( new_row );
  40.     };
  41. };
El efecto que produce el código es el siguiente:
Tengo un input file, al cual le hago click en Examinar y selecciono un archivo. Entonces me va a ir listando todos los archivos que vaya seleccionando. Hasta ahí vamos bien. Lo que yo quisiera es modificar este código, para poder enviar un array de rutas hasta mi servlet, entonces con ese array de rutas programo la lógica para subir los archivos al servidor, pero mi problema es mandar el array de rutas. Con "rutas" quiero decir por ejemplo C:\Documents and Settings\lCarlos\Mis documentos\Mis imágenes\hola.jpg.
Gracias de antemano por las respuestas