Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
122
rated 0 times [  124] [ 2]  / answers: 1 / hits: 43869  / 8 Years ago, sat, december 17, 2016, 12:00:00

I have a page that makes a foreach and show some photos like this



<% imgs.forEach(function(img) { %>
<img src=uploads/<%=user.username%>/screenshots/<%= img %>>
<% }); %>


And I want make a if statement because, in case that not photos to show gives a message like this:




no photos uploaded



More From » html

 Answers
18

Something like this:



<% if(imgs.length > 0){ %>
<% imgs.forEach(function(img) { %>
<img src=uploads/<%=user.username%>/screenshots/<%= img %>>
<% }); %>
<% } else{ %>
<p>no photos uploaded</p>
<% } %>


Reference


[#59669] Thursday, December 15, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
luna

Total Points: 698
Total Questions: 114
Total Answers: 93

Location: Israel
Member since Wed, Apr 14, 2021
3 Years ago
luna questions
;