J
Jake Barnes
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?
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?