Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
Deleting input file value

I have a table that consists of one form for every row (kind of inline editing) and some of the fields are of type file. For every of these files I create two buttons:

  • upload: upload a new image (grey)
  • delete: delete the previous image or do not upload what was selected (red)

What I want is to implement the delete functionality. the buttons look like this:

enter image description here

I already implemented the grey button and I want to avoid to create an extra API Endpoint for the delete image part of the table row.

<div>        
    <label for="{field.id_for_label}">
        <img src="images/x-square.svg">
    </label>
    <button type="button" onlick="delfunc()">
        <img src="images/upload.svg">
    </button>
</div>
<div class="text-body">
    filename: {field.initial}
</div>

How would I define a function onclick that either:

  • deletes the just selected input from the grey button and sets it to None or ""
  • make the whole form return None or "" for the file field (field.id_for_label) when save button is pressed

Please ignore the django-brackets around var names.

I tried to start with:

var delfunc = function() {document.getElementById('{field.id_for_label}').value = ''};
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!