Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda