Ver Mensaje Individual
  #13 (permalink)  
Antiguo 15/09/2005, 06:41
ratamaster
 
Fecha de Ingreso: octubre-2004
Ubicación: En algún lugar de la República Oriental del Uruguay
Mensajes: 366
Antigüedad: 19 años, 6 meses
Puntos: 0
Hola JavierB.
Te cuento que estoy usando tu script para crear input files dinamicamente, pero me faltaría una funcionalidad que no se como hacer.
Este es el códio con unas pequeñas modificaciones que le hice para agregarle un input text al lado de los campos file


Código PHP:
<html>
<
head>
<
title>Untitled</title>
<
script>
Num=0;
function 
Agregar(){
        
obj=document.getElementById('tabla');
        
f=document.getElementById('fila');
        
Num++;
        
elTr=document.createElement('tr');
        
elTd=document.createElement('td');
        
elTd.innerHTML='Foto '+Num+':';
        
elTr.appendChild(elTd);
        
elTd=document.createElement('td');

        
elem=document.createElement('input');
        
elem.type='file';
        
elem.name='foto'+Num;

        
elemTxt=document.createElement('input');
        
elemTxt.type='textarea';
        
elemTxt.name='txt'+Num//esto lo agregué
        
elemTxt.size='50';

        
elTd.appendChild(elem);
        
elTd.appendChild(elemTxt);

        
elTr.appendChild(elTd);
        
obj.insertBefore(elTr,f)
        }

/*esta función la cree, pero no es dinámica, necesito alguna manera que 
cuando haga el submit, la función sepa cuantos campos Foto fueron 
llenados*/
function Values(subirfoto){
        
valores="";
        for(
i=1;i<=2i++){//en este caso lo hice para dos campos nada más
            
valores valores + eval("subirfoto.txt"+i).value+",";
        }
        
alert(valores);
        }

</script>
</head>
<body>
<form enctype="multipart/form-data" method="post" action="#" name="subirfoto" onSubmit="return Values(this)">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
 <tbody id="tabla">
  <input type='hidden' name='usuario' value='1'>
   <tr>
    <td colspan="2" class="celda">
     <div align="center" class="titulo">
      Enviar Fotos para revelar
     </div>
    </td>
   </tr>

     <tr id="fila">
      <td colspan="2">
    <div align="center">
    <input name="enviar" type="submit" class="celda" value="Enviar">
    <input type="button" name="Submit" value="Agregar Foto" onClick="Agregar()">
    </div>
    </td>
    </tr>
   </tbody>
  </table>
 </form>
</body>
</html> 
Yo no se cuantas fotos un usario puede subir, por lo tanto, no se cuantos Foto1,Fotos2, etc, pueda haber, y yo necesitaría que cuando el usuario cliquee Enviar, se cree un array con todo los valores ingresados.
Espero haberme explicado bien.

Gracias
__________________
ratamaster

Última edición por ratamaster; 15/09/2005 a las 07:23