Web Analytics Made Easy -
StatCounter Clearing a file-type input field - CodingForum

Announcement

Collapse
No announcement yet.

Clearing a file-type input field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Clearing a file-type input field

    <input type='file' name='pdf'>

    This above displays an input box with browse button for selecting files to upload. If you browse and select a file, the path to that file shows up in the input box.

    I have a 'remove' button which, when clicked should clear the input box (but not the others in the form - so reset is out).

    I have tried the followingwith no luck:

    document.form.pdf.value = "";
    document.form.pdf= "";
    document.form.pdf.value.reset();
    document.form.pdf.reset();


    Is this is possible and if so, could someone please shed some light?


    Thanks.

  • #2
    For security reasons, file inputs are read-only. You can't set its value programmatically. What you can do is remember the values of the other fields then do a form reset and then set the values back.

    Or better, let the user delete the value manually.
    Last edited by glenngv; Mar 9, 2004, 01:49 AM.
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      let the user delete the value manually.
      How? that's what the remove button is supposed to be for.

      The user can select a file to upload but what if they then decide they don't want to anymore? they can only replace by selecting another file.

      Comment


      • #4
        They can delete the value in the file field just like the same way with other fields -- highlight the value, then press Delete button.
        Glenn
        vBulletin Mods That Rock!

        Comment

        Working...
        X