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

190
Vistas
How to pass Django formset form variable to JavaScript function

Basically I am using formsets, each form has a form ID and a deleted button amongst other things. When the delete button is clicked i'd like to call a function and pass the form ID to it, how can i achieve this?

{% for form in formset %}

{{ form.form_id_test }}

<button id="delete-form" type="button" class="btn btn-primary mb-2" 
onclick="deleteFormFunc({{ form.form_id_test }})">
    Delete Form
</button>

{% endfor %}

I am not able to pass the arguments like this, basically syntax error.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can obtain the form id of a formset form with form.id, eg,

{% for form in formset %}
    ...onclick="deleteFormFunc('{{ form.id }}')">...
{% endfor %}

...which should be a string value like 'id_form-1-id' that you can use in document.getElementById() in your deleteFormFunc

about 4 years ago · Juan Pablo Isaza Denunciar

0

    ...onclick="deleteFormFunc(this.id)">...

this.id will get the id of the tag it is encoded in.

about 4 years ago · Juan Pablo Isaza Denunciar
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