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 9 of 9

Thread: Form question

  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form question

    lo all,

    i want to reset a single field in a form. a file field to be specific.
    i cant seem to get it to work

    document.formname.formfield.reset(); doesnt work
    i've looked around and tried other options too, but none of 'em seem to work..

    help me plz ??

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    apologies - didn't mean to respond to this posting
    Last edited by martin_narg; 03-23-2005 at 02:23 PM.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    Code:
    document.formname.formfield.value='';

  • #4
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that doesn't work.

    it only works on text fields.

  • #5
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What are you trying to reset then?

  • #6
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm trying to reset a file field in a form.
    one with a browse button next to it.

  • #7
    Regular Coder
    Join Date
    Jan 2005
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it is a textbox then this code will work, do you have code that I can look at?

  • #8
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Input type=file is read only and for security reasons you can not manipulate it... the only way to reset that field without resetting the entire form is to remove and replace it with another simularly named field...

    Code:
    <script type="text/javascript">
     <!--//
      function reset_(file){ 
      // Written By: WillyDuitt@hotmail.com || 03-23-2005 \\;
         var input = document.createElement('input');
             input.type = file.type;
             input.name = file.name; 
             file.parentNode.replaceChild(input,file);
      }
      //-->
    </script>
    </HEAD>
    
    <BODY>
    <form action="http://google.com" method="get">
    <input type="file" name="file">
    <input type="text" name="text">
    <input type="button" value="Reset" onclick="reset_(this.form['file'])">
    <input type="submit">
    </form>
    .....Willy

  • #9
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sweet !

    that one works !

    thanks for the help guys. appreciate it.


  •  

    Posting Permissions

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