473,396 Members | 1,833 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,396 software developers and data experts.

Events for input type="file"

Hi all

I have a webpage where I want the user to input filenames. To make this easier,
I use a file input type so that the user can select files rather than typing in
the filename, using the HTML below.

<input type="file" size="25" maxlength="256" id="filename" onchange="AddFile()"
/>

The problem I have is that the javascript function AddFile() is only run under
Internet Explorer, and not under Mozilla. I need the function to run each time a
file is selected as the filenames are added to a text box (the user is creating
a list of files).

Is there some way of having this work under Mozilla?

Thanks.
Jul 23 '05 #1
2 43993
On Sun, 4 Apr 2004 01:42:25 +1200, @lias
<ki*****@yahoo.spammers.go.here.com> wrote:
I have a webpage where I want the user to input filenames. To make this
easier, I use a file input type so that the user can select files rather
than typing in the filename, using the HTML below.

<input type="file" size="25" maxlength="256" id="filename"
onchange="AddFile()" />

The problem I have is that the javascript function AddFile() is only run
under Internet Explorer, and not under Mozilla. I need the function to
run each time a file is selected as the filenames are added to a text
box (the user is creating a list of files).
The onchange event works very strangly with file-type INPUTs when the
"Browse" button is used. It doesn't fire at all in Mozilla, and the
control must lose focus for it to fire in Netscape. It fires as you expect
it to with Opera and IE. When changed via the keyboard, all of these
browsers will fire the event once the control loses focus.
Is there some way of having this work under Mozilla?


Use the onclick event in tandem with onchange. You'll have to keep a
record of the previous value though, to see if the value was indeed
changed, or if the control was simply clicked. A better alternative is to
use a separate button to call the AddFile() function.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2

"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:op**************@news-text.blueyonder.co.uk...
On Sun, 4 Apr 2004 01:42:25 +1200, @lias
<ki*****@yahoo.spammers.go.here.com> wrote:
I have a webpage where I want the user to input filenames. To make this
easier, I use a file input type so that the user can select files rather
than typing in the filename, using the HTML below.

<input type="file" size="25" maxlength="256" id="filename"
onchange="AddFile()" />

The problem I have is that the javascript function AddFile() is only run
under Internet Explorer, and not under Mozilla. I need the function to
run each time a file is selected as the filenames are added to a text
box (the user is creating a list of files).


The onchange event works very strangly with file-type INPUTs when the
"Browse" button is used. It doesn't fire at all in Mozilla, and the
control must lose focus for it to fire in Netscape. It fires as you expect
it to with Opera and IE. When changed via the keyboard, all of these
browsers will fire the event once the control loses focus.
Is there some way of having this work under Mozilla?


Use the onclick event in tandem with onchange. You'll have to keep a
record of the previous value though, to see if the value was indeed
changed, or if the control was simply clicked. A better alternative is to
use a separate button to call the AddFile() function.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)


Thanks for your help Michael. I guess I'll stick with adding a separate button.
Jul 23 '05 #3

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

Similar topics

1
by: Jesper Hermansen | last post by:
Hi! I'm making a system that will generate Winamp-playlists. To make it easy for the user to add a file to the list, I'm using <input type="file">. The problem with this is that I only get...
2
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds...
2
by: Laermans_k | last post by:
Hi, Does anyone have a solution to use the <input type="file" id="filechooser"> and the <input type="submit" id="submitbutton"> in 1 button click? I've already tried to create a javascript...
1
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic...
2
by: IkBenHet | last post by:
Hello, I am uploading a file using this form in ASP.NET. I have also added a simpel textfield: <form runat="server" enctype="multipart/form-data"> <input type="file" id="oFile" Name="oFile"...
2
by: Tarkeshwar | last post by:
Hi All, I want to restrict the user from being entering the value in <input type="file">. It works fine in IE but not in Mozilla. I am sending my code also which works in IE and not in Mozilla.Can...
3
by: eeeeman | last post by:
This one has really got me! Im trying to write a value to a input type="file" form element using client-side javascript. I have tried the obvious, simply writing: <input type="file" ...
1
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?>...
1
by: sandeep kumar shah | last post by:
Hi, We have used a file uploading HTML tag in an HTML page. We need to customize the text displayed on the Button (which is by default “Browse…” for internet explorer). Below is the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.