codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Cannot clear the value of a file object.  jrlaughlin at 15:40 on Monday, October 20, 2003
 

Hello all,

I have a file input on my page that I need to clear the value of in response to a button click. But setting the value of it to "" does not work.

Here is what I have:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test bed</title>
<script language="Javascript">


function clearIt(){
file = document.getElementById('filTest');
file.value = '';
alert(file.value);
}
</script>
</head>
<body>
<p>
<form name="ignoreThis">
<p>
<input type="file" id="filTest">
<br><input type="button" value="clear" onclick="clearIt();">
</p>
</form>
</p>
</form>
</body>
</html>


If you open the page in a browser and click the browse button to select a file then click clear, you would expect to get an alert box that says nothing. But it gives me the original value....and the value in the control does not change.

I have also tried setting the value to null and "", and "nothing". No change ever shows.


Anyone have any ideas?

Thanks.

James.

  Re: Cannot clear the value of a file object.  landy at 23:19 on Tuesday, December 02, 2003
 

"value" is read-only for <input type=file>

http://www.msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/value_6.asp for more info










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: JavaSript Problem In Mac Safari Browser
•  Re: DHTML div positionning Problem
•  Convert script to NS6 compatible - Please Help!
•  Print .doc file from the website using System.Diagnostics.Process
•  Re: Fullscreen code
•  Re: iframe targeting
•  Excel n ASP
•  Remote Cart Shopping Cart
•  Mouse click coordinates on an ActiveX control?


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005