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

145
Vistas
JavaScript and HTML button

I'm working on a Django project and I'm trying to add buttons that onclick direct you to another page, on a table that is built from a model.

Here is the HTML for the table: https://i.stack.imgur.com/uzddu.png

And here is the JS function: https://i.stack.imgur.com/lLas9.png

On the site this looks like this:

https://i.stack.imgur.com/jAZ76.png

The first button where the ID is 1 when clicked takes me to the right page. The second button though is not doing anything check clicked. What I'm trying to achieve is every time an application object is created and the table is updated I want the to be able to click the button and go to a page with a url like this: /review/id wit the id being the same as the one on the table.

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

0

You shouldn't have multiple buttons with the same ID's, ID's should be unique. Try giving the buttons a class, and linking the onclick to these classes.

<button id="review{{ app.id }}" class="btn btn-primary reviewBtn" data-id={{app.id}}">Review</button>
var reviews = document.getElementsByClassName("reviewBtn");
var redirect = function() {
    @TODO
};


for (var i = 0; i < reviews.length; i++) {
    reviews[i].addEventListener('click', redirect, false);
}

see this demo

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