473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how does one blank a file input in older versions of IE?


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.getEl ementById &&
document.getEle mentById(idOfFi leInputToBeMade Blank)) {
var referenceToFile Input =
document.getEle mentById(idOfFi leInputToBeMade Blank);
referenceToFile Input.value = "";
referenceToFile Input.innerHTML = "";
}

However, this will probably break in old versions of IE. So what works
for older versions of IE?

Sep 11 '06 #1
2 1381
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.getEl ementById &&
document.getEle mentById(idOfFi leInputToBeMade Blank)) {
var referenceToFile Input =
document.getEle mentById(idOfFi leInputToBeMade Blank);
referenceToFile Input.value = "";
referenceToFile Input.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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 12 '06 #2

Randy Webb wrote:
if (document.getEl ementById &&
document.getEle mentById(idOfFi leInputToBeMade Blank)) {
var referenceToFile Input =
document.getEle mentById(idOfFi leInputToBeMade Blank);
referenceToFile Input.value = "";
referenceToFile Input.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.
I appreciate your answer, but it looks like it will blank the whole
form. It's important that the form keep its information, as the user
has input it, and instead we merely blank the one input.

Sep 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1979
by: Martin | last post by:
I don't know if this is a PHP problem or a MySQL problem - hopefully, someone here can give me a clue. I am getting the subject error when I try to connect to MySQL from a PHP page. $conn = mysql_connect( $domain, $user, $password ); I'm using PHP 5.0.1 and MySQL Server: 4.1.9; Client: 5.0.0 Running on Windows XP (IIS, of course)
7
16217
by: Martin | last post by:
Again drawing on the groups experience:- 1. For general file opening and file saving, using VB6, are there any issues with using the FileOpen and FileSave Common Dialog Boxes? 2. Is using the FileOpen and FileSave Common Dialog Boxes the best way to go in general? 3. For Most of my projects I will be using the same types of data input form and report output form, as discussed here recently. Also, the files that are
6
4272
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a while statement checking for an empty string "" which I understand represents an EOF in Python. The text file has some blank lines with spaces and other with blanks. Thanks a lot.
1
2051
by: juppie | last post by:
Hello, I'm writing visual XML editor. At the moment I need a DTD parser which will parse DTD (either standalone or internal to XML doc) and give me an access to underlying DTD in convenient manner. What I need especially is API that will answer to questions: - what elements are defined in DTD - what elements can be inserted before/after particular element
1
2377
by: Erik Cruz | last post by:
Hi. I know that different .net framework versions can live together, but can I install the newer .net framework 1.1 and after that install the older .net framework 1.0 version? Or do I need to install the old one first and after that the newer one? TIA, Erik Cruz
1
3246
by: jcwmtl | last post by:
Hello all I'm building a suite of free php applications to create virtual worlds. My problem is i can't get my file to refresh. Can this be done with javascript? I would like to have the display and the form be on a single page..unless this can be done with frames. The sample application contains 2 files: a)The php file (with input controls and the embedded world) b)The embedded world (text file)
7
2369
by: Craig | last post by:
Hi I am trying to debug a problem with some ASP pages when accessed via IIS on Windows 2003 Server SP1. In summary, the pages are structured as follows: Root page Page loaded via IMG SRC Root Page extract >>>
8
2494
by: JM | last post by:
I installed a webserver based on scientific linux 4.4 yesterday (not my idea, but my bosses) and after doing all updates (apt-get and yum) the version of PHP was 4.3.9. Current version (at least for PHP4) is 4.4.6. 4.3.9 is 2.5 years old. Scientific linux is based Red Hat Enterprise Linux so I took a look there: same thing, but it mentioned that bugfixes were backported. What exactly does this mean ? Does it mean that all/some of the...
7
5873
by: beachdog | last post by:
I'm using Visual Studio 2005/C# to build a web client. The web server is something I've written in a different framework, which does not support generating wsdl, so I have hand-built a wsdl file, then created my proxy class by running wsdl.exe. The problem is that the SOAP message that the client generates contains an empty namespace for the parameters in my message, instead of the namespace I intended it to have. I am guessing it is...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.