title: Why is the image source unknown?
body: <p>When i use javascript in a jinja for loop to dynamically change the image source, it only works for the first image.
  The entire loop runs except the image part where the image source becomes unknown when there is more than one item created.</p>
  <pre><code>{% for i in restadmin %}
      &lt;input type=&quot;text&quot; name=&quot;&quot; value=&quot;{{i.iname}}&quot; hidden=&quot;true&quot; id=&quot;pname&quot;&gt;
      &lt;div class=&quot;col-sm-6 col-md-4&quot;&gt;
        &lt;div class=&quot;menu menuName0 thumbnail&quot; id=&quot;&quot;&gt;
      
          &lt;h3&gt;{{ i.iname }}&lt;/h3&gt;
          &lt;div&gt;
            &lt;img src=&quot;&quot; id=&quot;productimage&quot; class=&quot;img-responsive&quot;&gt;
          &lt;/div&gt;
          &lt;script&gt;
            var pname = document.getElementById(&quot;pname&quot;).value
            var image = document.getElementById(&quot;productimage&quot;)
            console.log(pname)
            image.src = &quot;../static/images/product_image/&quot; + pname + &quot;.png&quot;
          &lt;/script&gt;
          &lt;h1&gt;&lt;/h1&gt;
          &lt;h5 class=&quot;caption &gt; p&quot;&gt;{{i.idesc}}&lt;/h5&gt;
          &lt;h4 class=&quot;price&quot;&gt;${{i.iprice}}&lt;/h4&gt;
          &lt;input type=&quot;text&quot; id=&quot;{{ i.iid }}a&quot; name=&quot;a&quot; src=&quot;&quot; rows=&quot;1&quot; cols=&quot;3&quot; value=&quot;{{ i.iprice }}&quot; readonly style=&quot;border: none;background-color: transparent; outline: none; text-align: center;&quot; hidden=&quot;true&quot;&gt;
          &lt;input type=&quot;text&quot; id=&quot;{{ i.iid }}b&quot; name=&quot;b&quot; value=0 readonly hidden=&quot;true&quot;&gt;
      
          &lt;!-- &lt;button class=&quot;btn-order&quot;&gt;&lt;glyphicon class=&quot;glyphicon glyphicon-shopping-cart&quot;&gt;&lt;/glyphicon&gt; Commander&lt;/button&gt; --&gt;
          &lt;button class=&quot;btn-order&quot; id=&quot;{{ i.iid }}&quot; name=&quot;{{ i.iid }}&quot; onClick=&quot;additem();&quot;&gt;Add&lt;/button&gt;
          &lt;button class=&quot;btn-order btn-danger navbar-btn&quot; id=&quot;{{ i.iid }}&quot; name=&quot;{{ i.iid }}&quot; onClick=&quot;removeitem();&quot;&gt;Remove&lt;/button&gt;
      
        &lt;/div&gt;
      &lt;/div&gt;
  {% endfor %}
  </code></pre>