0
 {% for i in range(counter) %}
            {% set count = 0 %}
            <div class="tablerow balls" name={{count}}>
                <div class="positionz colors rowitem"><div class="cellvalue gposition">{{(job[i]["position"])}}</div>
                <button class="edit"><img src="{{ url_for('static', filename='img/pencil.png') }}" width="40px" height="40px"></button>
            <button class=submitedit>Submit Edit</button></div>
                <div class="companyz colors rowitem"><div class="cellvalue gcompany">{{(job[i]["company"])}}</div>
                <button class="edit"><img src="{{ url_for('static', filename='img/pencil.png') }}" width="40px" height="40px"></button>
                <button class=submitedit>Submit Edit</button></div>
                <div class="descriptionz colors rowitem"><div class="cellvalue gdescription">{{(job[i]["description"])}}</div>
                <button class="edit"><img src="{{ url_for('static', filename='img/pencil.png') }}" width="40px" height="40px"></button>
                <button class=submitedit>Submit Edit</button></div>
                <button class="delete"> <img src="{{ url_for('static', filename='img/minus.png') }}" width="40px" height="40px"></button>
                <label class="switch">
                    <input type="checkbox" class="highlight">
                    <span class ="slider"></span>
                </label>
            </div>
            {% set count = count + 1 %}
            {% endfor %}

I have tried to find a way to properly utilised count but it seems no matter what I do it won't work properly.

Bobby
  • 37
  • 2
  • 10
  • Does this answer your question? [How to increment a variable on a for loop in jinja template?](https://stackoverflow.com/questions/7537439/how-to-increment-a-variable-on-a-for-loop-in-jinja-template) – buran Mar 09 '20 at 21:33
  • 1
    Gosh, we just crashed SO a bit there, @buran. We must have voted as dupe at exactly the same time because my dupe hasn't given a comment, nor an upvote to yours, but we had the same target :) – roganjosh Mar 09 '20 at 21:34
  • "It wouldn't work for me" is not really useful for us to try and understand the issue. You need to be specific – roganjosh Mar 09 '20 at 21:35
  • So when i used the count function it doesn't update the counter at at all. If I set my counter to 1 it stays at 1 no matter what. – Bobby Mar 09 '20 at 21:38
  • See also [How to output loop.counter in python jinja template?](https://stackoverflow.com/q/12145434/4799172) – roganjosh Mar 09 '20 at 21:38
  • @Bobby you set counter to 0 at the beginning of each loop. This should be done outside of the loop (before the for tag). Then, you should probably not loop on a range but instead loop over the job list. If you still need to display the count (or use it as an attribute), as roganjosh said you can use loop.counter – rolf82 Mar 09 '20 at 21:58

0 Answers0