You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Slattery, Tim - BLS" <Sl...@bls.gov> on 2004/08/12 15:57:22 UTC

RE: works on ly in Internet Explorer

> The following works only in Internet Explorer, not in 
> Mozilla, Netscape or Opera.  Anyone have any idea how to fix it?
> 
> 
> <html:form method='POST' enctype='multipart/form-data' 
> action='/upload'>
>    <html:file property='browse' value='' style='display: none;' />
>    <html:text property='file' value=''/>
>    <html:button property='whatever' 
> onclick='browse.click();file.value=browse.value;browse.disabled=true' 
> value='Select a File...'/>

Mozilla hues to the W3C standard for addressing items in the DOM. That means
that instead of using the easier syntax that IE accepts, you have to find an
item using the get ElementById function. So write a JavaScript function that
looks something like this:

Function getFile()
{
     fileCtrl = document.getElementById("browse");
    textCtrl = document.getElementById("file");
    fileCtrl.click();
    textCtrl.value = fileCtrl.value;
}

And call it from the onclick property of your button. I suspect you're going
to have to get a bit fancier, because you don't want to assign the value
until the user has changed the value of the file selector. Maybe an onChange
handler in that control?


--
Tim Slattery
Slattery_T@bls.gov


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org