CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Scripting - Client Side
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    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.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old July 3rd, 2002, 08:32 AM
    drcb drcb is offline
    Junior Member
     
    Join Date: Jul 2002
    Location: Germany, Mannheim
    Posts: 2
    drcb is an unknown quantity at this point (<10)
    Question .click() method behaves strange with <INPUT TYPE=FILE>

    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.
    Reply With Quote
      #2    
    Old September 27th, 2002, 07:28 PM
    websmith99 websmith99 is offline
    Member
     
    Join Date: Aug 2002
    Location: Reykjavik, Iceland
    Posts: 201
    websmith99 is an unknown quantity at this point (<10)
    This is interesting. When I changed your Submit link to a
    Submit button the form would submit.... after you pressed the
    button TWICE.
    Reply With Quote
      #3    
    Old September 30th, 2002, 03:49 AM
    drcb drcb is offline
    Junior Member
     
    Join Date: Jul 2002
    Location: Germany, Mannheim
    Posts: 2
    drcb is an unknown quantity at this point (<10)
    Exclamation I know this effect.

    When using submit button it works only after second click. But sends an empty form .
    __________________
    Artem
    Reply With Quote
      #4    
    Old October 14th, 2005, 05:51 AM
    vikasm123 vikasm123 is offline
    Junior Member
     
    Join Date: Oct 2005
    Posts: 1
    vikasm123 is an unknown quantity at this point (<10)
    Angry Re: .click() method behaves strange with <INPUT TYPE=FILE>

    This code is working on IE,
    but it is not working on mozilla,
    please look into this.
    Reply With Quote
      #5    
    Old October 14th, 2005, 11:20 AM
    PeejAvery's Avatar
    PeejAvery PeejAvery is offline
    Super Moderator
    Power Poster
     
    Join Date: May 2002
    Location: United States
    Posts: 8,969
    PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)PeejAvery has a brilliant future (2000+)
    Re: .click() method behaves strange with <INPUT TYPE=FILE>

    Quote:
    Originally Posted by drcb
    When using submit button it works only after second click. But sends an empty form .
    Could this be because you are getting the $_POST of the text instead of the file value???

    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.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Scripting - Client Side


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 05:28 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009