Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/02/2010, 01:51
vesvello
 
Fecha de Ingreso: noviembre-2007
Mensajes: 118
Antigüedad: 16 años, 6 meses
Puntos: 0
gif carga mientras sube foto

partiendo del codigo que encontre en este post:
http://www.forosdelweb.com/f13/gif-c...4/#post2299377
hice las siguientes modificaciones:
Este es el codigo que crearia los input file:

Código HTML:
 <script>
	function ShowFields(x)
	{
		var iFields = parseInt(x.options[x.selectedIndex].value);
		
		var strCode = "";
		
		strCode +="<table border=\"0\" cellspacing=\"8\">";
		
		for(i=0;i<iFields;i++)
		{
			strCode +="<tr>";
  				strCode +="<td>Image "+(i+1)+":</td>";
  				strCode +="<td> <input type=file name=userfile"+(i+1)+"><img id='loading' src='ajaxloader.gif' width='16' height='16' style='display:none' /></td>";
  			strCode +="</tr>";
		}
		
		strCode +="</table>";
		
		document.getElementById("UploadFields").innerHTML = strCode;
		
	}
	</script> 
Este seria el que al onsubmit ejecuaria la funcion loading
Código HTML:
 <form action="index.php" style="margin-top:0px;margin-bottom:0px" method=post name="form2"  ENCTYPE="multipart/form-data"onsubmit="return loading()"> 
Por ultimo la funcion loading que cargaria la imagen gif mientras se carga el archivo:
Código HTML:
<script>
		function loading()
		{
	var images_number = document.getElementById('images_number').value;
	var iPicCounter = document.getElementById('iPicCounter').value;
	var imagenes_subir = images_number - iPicCounter;
	alert (imagenes_subir);
	for (var i=0; i < imagenes_subir; i++)
		{
	if(document.getElementById('userfile'[i]).value.length)document.getElementById('userfile'[i]).style.display='inline'
		}
</script> 

Pero me dice que loading no es una funcion.
No tengo mucha idea de javascript asi que se agradecen sugerencias