473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Clearing the content of an input field

Claus Mygind
571 512MB
I get the following code to work in FireFox but not in IE v8

Expand|Select|Wrap|Line Numbers
  1.     document.getElementById('MyFile').value = ""
  2.  
When I examine it in the IE debugger, I can see that the code appears correct because when I put a watch on the statement it returns the current value.

Why would this line then not clear out the content?
Dec 15 '10 #1
4 1686
JKing
1,206 Expert 1GB
What kind of element is it? You may need to use innerHTML instead of value.
Dec 15 '10 #2
Claus Mygind
571 512MB
I tried innerHTML and that just created an error.

the field was just an <input type="file" />
Dec 16 '10 #3
JKing
1,206 Expert 1GB
Not sure, that original line works for me in both FF and IE8. Could you post the rest of your javascript?
Are there javascript errors in IE?
Dec 16 '10 #4
acoder
16,027 Expert Mod 8TB
Try using reset instead. If that's going to be a problem, you could put the field in its own form.

There's a hack you could use where you replace the element with a new one either via DOM, or by refreshing the innerHTML (a proper hack).
Dec 16 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ben | last post by:
Hi all, i have file input field in a form like this: <input name="isbn" type="text" size="25" value="<?php echo $_POST ?>" /> <input name="image" type="file" size="25" value="<?php echo...
1
by: efiedler | last post by:
Hi - I have the following input field on my html page: <input type="image" name="submit" id="submit" src="c:\image.jpg" value="image.jpg"> I also have another input field on the form that is...
2
by: Rosebud | last post by:
Hello, I'd like some help trying to generate input fields on the fly. What I have on an HTML page is a single text input field labelled #1, e.g. #1 <input type="text">. Next to the field is a...
7
by: JW | last post by:
hello everybody I've got the following problem. I'm writing a form and I'm using javascript to validate fields (i.e. numeric, not blank). When my scripts detects an error I want it to put the...
13
by: Lee | last post by:
I have this function that doesn't work. I pass it the td element and an id, and it makes an input field inside the td. That part workds. What doesn't work is that I want to add an "onkeyup" on...
1
by: Will_uk | last post by:
I am trying to return focus to a form input field. If i use <form>.<field>.focus() the focus returns to the field but if the field already contains a value it selects it (blacks it out). Is it...
2
by: bucchi | last post by:
Hi, I have an input field and I have to change the background color when the contents change. The contents are changed by a pop-up. On submit of the pop-up the contents change.How can I...
9
by: keydrive | last post by:
There must be a difference between a standard input field and a textbox field. I would like to use a textbox field and save the value in a hidden field for paging. This works in a default input...
1
by: anonymousstar | last post by:
Hi Everyone, I am creating a search facility that holds titles and SKU numbers. When the results appear in a 2 column table I would like the title to go into an input (readonly) field and the SKU...
4
by: mfaisalwarraich | last post by:
Hi everybody, I have some problem so need some help. wat im trying to do is making a function which will change the value of a input field when the value of other input field is changed. im using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.