Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda