How can you increment variables in Javascript?

no problem

       {% for title, poster in pics_data.items() %}
   {% if title == movie %}
   <div class="poster_container">
   <img src="{{ poster }}" class="poster" alt="{{ title }}" onclick="info();"/>
<script type="text/javascript">
       var images = [];
        images.push("{{ title }}")
       </script>

   </div>
   {% endif %}
   {% endfor %}

     {% for title, summary in summaries_data.items() %}
      {% if title == movie %}
      <p class="summary-row"><br>{{ summary }}</p>

    <script type="text/javascript">

        var summaries = [];
            summaries.push("{{ summary }}")

        function info() {
                for(var i = 0; i < images.length; i++) {
                    for(var j = 0; j < summaries.length; j++) {
                    if(images[i] == "{{ title }}") {
                        alert(summaries[i])
                    }
                    }
                }
        }

       </script>

        {% endif %}
    {% endfor %}                               

  </div>

{% endfor %}

the problem is when the javascript is called outside of the loop, it only alert's the last element of the array.

it would probably help if i explain what im trying to do. this is an application that loads 5 movies. you click on the cover art for one of the movies, and you should see the corresponding summary, but the last summary in the javascript array is the only one that loads.

if i can get the summaries in memory but outside of the flask loop, i can do specific targeting and should be able to accomplish this easier

/r/learnjavascript Thread Parent