Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Programmatically invoke the file browse dialog of input type=file


  • From: newtquest at yahoo.co.uk (Gaz Newt)
  • Subject: [Javascript] Programmatically invoke the file browse dialog of input type=file
  • Date: Fri Sep 29 15:42:33 2006

I want to have a separate button which invokes the "browse" button on an input type=file. In internet explorer the following code works ok, in firefox nothing happens.

All I do is call click() for the input control.

Do you know how to make this work in firefox?

Thanks


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

<head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <script type="text/javascript">
    function test()
    {
        var oTest = document.getElementById( "mytest");
        oTest.click();
    }
    </script>
</head>

<body>

<form id="myform" action="test.aspx" method="post">
    <input type="file" id="mytest" value="monkey" />
    <br />
    <input type="button" value="Programmatically Invoke The File Browser Dialog" onclick="javascript:test();" />
</form>
</body>

</html>

 		
---------------------------------
 The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.LaTech.edu/pipermail/javascript/attachments/20060929/73059be0/attachment.html