+ Start a Discussion

How to retrieve file name using tag 'InputFile' in Firefox

Hello Friends,


I have a requirement wherein i need to check if i have a file name selected while using the InputFile tag.


It is working well in IE, but somehow not working in FireFox!!


The notation i am using is -  document.getElementById("page:form:id:inputfile:file").value 


This somehow is not recognized in Firefox. Can anyone let me know how to handle this cross browser issue??


Many Thanks,





I'm wary of hardcoding element ids using the standard 'page:element1:element2'. Salesforce could change teh way they build ids at any time, and you have to update the id if you change the nesting of the element within the page. To get around this limitation I would usually use javascript inline with my component to get the elementById e.g.







<apex:inputField id="myComponent" ... />

<script> var theComponent = document.getElementById("{!$Component.myComponent}"); </script>








You can then use this JS var in any other JS within the page.




Message Edited by wesnolte on 06-17-2009 09:30 AM