Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
see this code guys.
click() doesn't work on FireFox but it's working on IE.

<script>
function attachFile(){
  document.getElementById("file").click(); 
}
</script>

<form name="novsh" style="margin: 0px; padding: 0px;">
    <input type="file" name="file" style="display:none" id="file" />
</form>

<a href="javascript:attachFile()">Attach File</a>
<input type="button" name="btn" value="click me" onclick="attachFile()" />

Regard T.
Posted
Updated 2-Jun-10 4:18am
v4
Comments
Sandeep Mewara 14-May-10 11:43am    
Thats why i asked you to debug it in FF, i had a doubt but was not sure. Great you got it resolved though!
T-Joe 14-May-10 11:48am    
Great me? kkk

1 solution

It might be FF is not resolving the name of control as given.

Ok, first of all put an alert just before click line and see if document.getElementById("file") is being shown as Object or not.

If so, debug it and check that whether 'document.getElementById("file")' has the event click in it.

P.S.: perform all these in FF as thats where the issue is.
If you are able to resolve after this ok, or else tell us what you find.
 
Share this answer
 
Comments
T-Joe 14-May-10 11:40am    
I've just found out something to do with click() function.
It exists only in IE. So IE can able to understand click and obey

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900