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)