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.