🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #662

Re: Resetear el valor del texto de Type="file"

#662
From: Flint
Date: Sun, 18 Feb 2007 15:19
43 lines
1986 bytes
Paul escribi�:

> 
> Hola,
> 
> Esto que me dices no me funciona si  type="file".
> 
> Gracias
> 


Tienes toda la raz�n. No se puede hacer por motivos de seguridad (se me 
hab�a pasado el type="file" :-P

As� que la soluci�n pasar�a por cargarse el input entero y volver a 
crearlo nuevo. La manera m�s sencilla de hacerlo es metiendo el input en 
un div y jugar con el innerHTML, tal que as� (no necesitas ya el id del 
input, sino que lo pondremos en el div):
	<div id="txtImg1">
		<input name="txtImg1" type="file" size="50" maxlength="100">
	</div>

El bot�n, o lo que sea que limpie, seguir� llamando a la funci�n:

	<input type ="button" onclick="limpiar()" value="Limpiar"/>

Y la funci�n quedar�a as�:

<script type="text/javascript">
          function limpiar(){
          	txtImg1.innerHTML='';
		txtImg1.innerHTML='<input name="txtImg1" type="file" size="50" 
maxlength="100">';
          }
  </script>



Y ya.

-- 
Un saludo, Flint
Gijon Fortuna (773926) www.fibha.com
Technical Details
Message-ID: <53r94hF1tq4p5U1@mid.individual.net>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <1171800914.372856.123820@v45g2000cwv.googlegroups.com> <53qvtnF1u67mrU1@mid.individual.net> <1171810389.588026.290890@q2g2000cwa.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1116f3,488dfd7adce2523f
X-Google-Attributes: gid1116f3,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Flint <dirfalsa@terra.es>
Newsgroups: es.comp.lenguajes.java
Subject: Re: Resetear el valor del texto de Type="file"
Date: Sun, 18 Feb 2007 16:19:44 +0100
Lines: 43
Message-ID: <53r94hF1tq4p5U1@mid.individual.net>
References: <1171800914.372856.123820@v45g2000cwv.googlegroups.com>   <53qvtnF1u67mrU1@mid.individual.net> <1171810389.588026.290890@q2g2000cwa.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net ngClFkz6X+s6fYVsgCnVwwP+IJbocWnqhEtgo8KgDClIeW4U0T
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
In-Reply-To: <1171810389.588026.290890@q2g2000cwa.googlegroups.com>