Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!