Jake Barnes said the following on 9/11/2006 4:38 PM:
At a certain point in my code, I need to blank the value in a file
input. The situation comes up when a user first thinks they want to
upload something from their harddrive, but then they change their mind
and decide to choose a file from an online archive. I thought I could
get a reference to the input and then set value to blank, but that only
works in FireFox. For IE, I only got this to work by setting innerHTML
to blank:
if (document.getElementById &&
document.getElementById(idOfFileInputToBeMadeBlank )) {
var referenceToFileInput =
document.getElementById(idOfFileInputToBeMadeBlank );
referenceToFileInput.value = "";
referenceToFileInput.innerHTML = "";
}
However, this will probably break in old versions of IE. So what works
for older versions of IE?
The same thing that will work in any browser that supports form
manipulation:
document.forms['formID'].reset();
Voila! Your file input is blank.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/