+ Start a Discussion
Cool_DevloperCool_Devloper 

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,

Cool_D

wesnoltewesnolte

Hey

 

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:page>

.

.

.

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

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

.

.

.

</apex:page>

 


 

 

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

 

Cheers,

Wes 

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