1
good afternoon. I used a carousel to make a simple image gallery. I numerically named the names of the photos (1.JPG, 2.JPG, 3.JPG, ... , n.JPG) Doing "manually" (ie when I type in the entire code by inserting each image from the photo folder), it obviously works fine.
But I’d like to do this with a loop. But there’s something wrong, I think maybe it’s in the concatenation.
Follow the code, in the example below, I have 29 images.
<div id="galeria" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/1.jpg" class="d-block w-100" alt="...">
</div>
<% For i=2 to 29 %>
<div class="carousel-item">
<img src="img/"<% & i & %>".jpg" class="d-block w-100" alt="...">
</div>
<% Next %>
</div>
<a class="carousel-control-prev" href="#galeria" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Anterior</span>
</a>
<a class="carousel-control-next" href="#galeria" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Próxima</span>
</a>
</div>
Any idea?
thanks!!! that’s right! I knew the problem was in <%& i & %>, I just didn’t know how to fix it!
– user78432