| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Scripting - Client Side Discuss client-side scripting issues. Client-side scripting such as JavaScript, JScript, and VBScript as well as technologies such as HTML and stylesheets. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm trying to workaround style problem with "Browse" button in the <INPUT TYPE=FILE> (as far as I know - it is impossible to alter color, font and other style stuff of this button). So I invented to hide this fileupload control and make wrapper input control, which only calls methods from hidden fileupload.
Code is following: <html> <body> <h>This is a test</h><br> <form id="frm" method="POST" enctype="multipart/form-data"> This should be <input type="button" onclick="document.all.f.style.visibility='hidden';" value="Hidden"><br> <input type=file name="f" style="visibility: visible;"><br> This is for user:<br> <input type="text" name="t" readonly=true style="border-color: green; font-color: red;"> <input type="button" name="b" value="BrowZe.." onclick="document.all.f.click(); document.all.t.value=document.all.f.value;" style="border-color: green;"> <br> <a href="javascript:document.all.frm.submit();">Submit</a> </form> </body> </html> Now if I click native "Browse" button, select a file and then click "Submit" - all works as expected. But if I click wrapper "Browse" button, select a file and then click "Submit" - I get "Access denied" exception. Note: I'm not trying to write any data into file upload control, I'm only reading and calling its .click() method. And it works (shows file selection dialog, and correctly fills filename). But after this action browser goes into strange mode, when calling .submit() causes "Access denied" exception. Is it MSIE's bug? Is there workaround for this?
__________________
Artem Last edited by drcb; July 3rd, 2002 at 08:54 AM. |
|
#2
|
|||
|
|||
|
This is interesting. When I changed your Submit link to a
Submit button the form would submit.... after you pressed the button TWICE. |
|
#3
|
|||
|
|||
|
When using submit button it works only after second click. But sends an empty form
.
__________________
Artem |
|
#4
|
|||
|
|||
|
This code is working on IE,
but it is not working on mozilla, please look into this. |
|
#5
|
||||
|
||||
|
Re: .click() method behaves strange with <INPUT TYPE=FILE>
Quote:
The following code will work in IE only. I am looking into why it will not for Firefox. The submit button being clicked twice is just something that you have to deal with. It has to do with hiding a file input box. Extra mouse clicks are being processed. Code:
<html>
<body>
<style>
.uploadbtn{
border-color: #00ff00;
}
.uploadtxt{
color: #ff0000;
border-color: #00ff00;
}
</style>
<form name="frm" method="post" action="file.php">
<input type="file" name="filename" style="display:none">
<br>
<input type="text" name="path" readonly="true" class="uploadtxt">
<input type="button" name="btn" value="BrowZe.." class="uploadbtn" onclick="frm.filename.click();frm.path.value=frm.filename.value">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
__________________
If the post was helpful...Rate it! Remember to use [code] or [php] tags. |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|