Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    217
    Thanks
    25
    Thanked 1 Time in 1 Post

    hiding file and submit field after submit

    I've got the following 2 fields in my form:

    <input type="file" name="filename" id="filename" value="filename">
    <input type="submit" name="submit" value="Upload Image" />

    Now I want to hide both of them as soon as the submit button is pressed. Problem is that I'm a javascript noob and I can't find it with google :S

    Can someone help me?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,021
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Code:
    <div id="hider">
       <input type="file" name="filename" id="filename" value="filename">
       <input type="submit" name="submit" value="Upload Image" 
              onclick="document.getElementById('hider').style.display='none';return true;" />
    </div>
    Or, if it's not convenient to have the two fields in the same <div>,
    Code:
    <input type="file" name="filename" id="filename" value="filename">
    <input type="submit" name="submit" value="Upload Image" 
           onclick="this.form.filename.style.display = this.style.display = 'none'; return true;" />
    p.s.: No real reason to have an id for that <input> field, you know.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •