Comunidad de diseño web y desarrollo en internet online

onchange en input file

Citar            
MensajeEscrito el 12 Sep 2009 06:33 pm
Tengo un input de tipo file que ejecuta una funcion cuando se selecciona un archivo mediante el evento onchange

Código HTML :

<form><input type="file" onchange="mifuncion();"></form>


pero esa funcion se ejecuta tambien cuando se le da cancelar al open/save dialog que aparece al darle al boton examinar.

¿como puedo hacer para no ejecute la funcion si el usuario presiona "cancelar"?

Por nodream

Claber

99 de clabLevel



 

opera
Citar            
MensajeEscrito el 12 Sep 2009 11:34 pm
nodream

Hola man!!! yo lo estuve revisando y solo se activa la función cuando se cambia el contenido del input, pero no reacciona al botón cancelar

Por esutoraiki

Claber

548 de clabLevel

4 tutoriales

Genero:Masculino  

Aplicaciones para Web

opera
Citar            
MensajeEscrito el 13 Sep 2009 09:33 am
Al parecer esto solo pasa en chrome

aqui dejo el codigo

Código HTML :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" >
function muestrame(){
   alert("me has cambiado");
   return false;
}
</script>
</head>
<body>
<form name="form1">
   <input type="file" name="archivo" onchange="muestrame();"/>
</form>
</body>
</html>


Aunque por ahi me pasaron el tip y con un pequeño if el problema se ha resuelto por ahora.

Código HTML :

   <input type="file" name="archivo" onchange="if(!this.value.length)return false; muestrame();"/>


Gracias

Por nodream

Claber

99 de clabLevel



 

opera

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.