On Tuesday, November 29, 2011 12:54:45 PM UTC-5, thodoris wrote: > > Thanx for the reply, > > Well, whenever i put the cursor on the text area a popup window opens > to choose the file, so i can't edit the text. > You're right -- I guess it depends on the browser. In IE, you can delete the filename, but not in Chrome or Firefox.
> About the solution with Javascript, how can i reference the field that > i want to clear? > Form fields have a standard naming convention: http://web2py.com/book/default/chapter/07#CSS-Conventions. > I could do something like: > > form.append(INPUT(_type="button", _value="Clear", > _onclick="form.field[3]='';")) > You can't reference 'form.field' in your 'onclick' handler -- that has to be Javascript, and it must reference items in the client-side DOM (form.field is a server-side web2py object). Instead, you can add a link or button and a jQuery click event handler that does something like: <script> $(function() { //on document ready $('#clear_file').click(function(e) { //capture click event $('#mytable_myfield').val(''); //clear the file field e.preventDefault(); //prevent the default click behavior }); }); </script> Anthony > > On Nov 29, 4:25 pm, Anthony <abas...@gmail.com> wrote: > > Unless you're using a special widget, once you select a file for upload, > > the browser should simply put the filename in the string field next to > the > > browse button. You should be able to put the cursor in that string field > > and delete the filename. As an alternative, I suppose you could add a > > button/link with some Javascript that automatically clears the field when > > clicked. > > > > Anthony > > > > > > > > > > > > > > > > On Tuesday, November 29, 2011 10:18:32 AM UTC-5, thodoris wrote: > > > > > Hello, > > > > > I have this Field > > > > > Field('cover','upload',notnull=False,autodelete=True), > > > > > When the form is displayed you click on browse you can select the > > > file. But once a file is selected you cannot undo your choice. There > > > is always the choice to reload the page that holds the form and clean > > > the field but is there another way to do it?? > >