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

186
Visualizações
Javascript function inside Django Loop runs only once

In my template, i generate each table row within a django for loop, I have this function that formats strings the way I want, but it's working only in the first row of the table, I dont know why.

enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Well the problem is basically that in HTML you can't have two elements with the same id, and you are calling them cpfpg then is logic that the first row is ok because you have only one element with that id but after that you have more than one element with the same id and that's the problem.

I think you can change it id="cpfpj{{forloop.counter}}" then you can do in your javascript:

ele = document.getElementById("cpfpj{{forloop.counter}}")

It just fix your problem.

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