You are viewing limited content. For full access, please sign in.

Question

Question

js delete file from upload field

asked on December 15, 2018

Hi - I'm trying to execute a bit of javascript to delete the files in an Upload field, and then save the empty field as updated to the Forms db when the form is submitted.

Assume we have a field "Upload1" with selector #q1, and it has a file(s) saved into it from a previous step in the process.  Upon loading the form for a later step, if we execute a remove on the files table with "$('#q1 table.files>tbody>tr').remove();", it appears to work in so much as the files are no longer shown in that field.  But, when the form is submitted, the files remain part of the instance in the database - the empty upload field does not overwrite the previous files.

If we take a different approach and act on the file delete button (the "X" at the end of the row) with "$('#q1 .file-del').trigger('click');" that does work, but it kicks off the confirmation modal which requires the user to click "Delete" in the confirmation box.  This is not acceptable, as we want the field to clear with javascript and no user action, and I don't know of a way to bypass the modal.

Any ideas?

Thanks, .... Steven.

 

0 0

Replies

replied on August 20, 2020

Aloha Steven. Running into this same issue here in 2020. Hoping you are still out there and ended up finding a solution you can share.  Thanks for any help/input you can provide.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.