PDA

View Full Version : tag "FILE" empting


hryan
07-19-2002, 02:25 PM
Hi!
I have this

<input type="file" name="filename">

How can I empty this tag's value after pointing the file ?

this.form.filename.focus();
and
this.form.filename.select(); WORK RIGHT.


But
this.form.filename.value='';

does not work!

Thanks !

caldasgsm
07-19-2002, 02:44 PM
you can't....the value propertie of the file element is read-only:D

mordred
07-19-2002, 02:45 PM
That's not possible.
Due to security restriction, JavaScript has merely read-only access to a file-type input element.

Maybe resetting the form completely (document.form.reset()) is of any help to you, or you could try to remove the form element from the DOM and after that insert it anew.

tamienne
07-19-2002, 06:46 PM
You can reset the form, but then everything gets cleared.

caldasgsm
07-19-2002, 07:20 PM
nop
nop
and nop

you can't remove and then add a file element to the dom...

certain script operations on that element (almost every one) even that the browser does not give an error, break the 'safety' of the control and causes the element not to function proprely (doesn't upload)

adding the control to the dom is one of them

document.write('<input type=file....
x.innerHTML = '<input type=file....
is some of the many ways that would fail...

so i guess that the best way is actually reset the form...
if you don't whant the rest of the form to be cleared simply hold the values in variables and put them back in place after the reset

neil.c
07-19-2002, 07:41 PM
or put it in a separate form...

hryan
07-22-2002, 08:02 PM
Great THANKS for all of you!!!

Resetting form works great!! It's a solution for me!

Once again: BIG THANKS!
:p :thumbsup: