Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
Why is the image source unknown?

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.

{% for i in restadmin %}
    <input type="text" name="" value="{{i.iname}}" hidden="true" id="pname">
    <div class="col-sm-6 col-md-4">
      <div class="menu menuName0 thumbnail" id="">
    
        <h3>{{ i.iname }}</h3>
        <div>
          <img src="" id="productimage" class="img-responsive">
        </div>
        <script>
          var pname = document.getElementById("pname").value
          var image = document.getElementById("productimage")
          console.log(pname)
          image.src = "../static/images/product_image/" + pname + ".png"
        </script>
        <h1></h1>
        <h5 class="caption > p">{{i.idesc}}</h5>
        <h4 class="price">${{i.iprice}}</h4>
        <input type="text" id="{{ i.iid }}a" name="a" src="" rows="1" cols="3" value="{{ i.iprice }}" readonly style="border: none;background-color: transparent; outline: none; text-align: center;" hidden="true">
        <input type="text" id="{{ i.iid }}b" name="b" value=0 readonly hidden="true">
    
        <!-- <button class="btn-order"><glyphicon class="glyphicon glyphicon-shopping-cart"></glyphicon> Commander</button> -->
        <button class="btn-order" id="{{ i.iid }}" name="{{ i.iid }}" onClick="additem();">Add</button>
        <button class="btn-order btn-danger navbar-btn" id="{{ i.iid }}" name="{{ i.iid }}" onClick="removeitem();">Remove</button>
    
      </div>
    </div>
{% endfor %}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda