473,467 Members | 1,303 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 43996
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: 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
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.