Hi,
I have been trying to loop through a targetData variable using JSP.
In my workflow I have got 6 images. All of them are stored as below:
targetData.image1
targetData.image2
targetData.image3
targetData.image4
targetData.image5
targetData.image6
Instead of printing them separately, I want to run a loop and print it.
<% for(int i=0; i<6; i++) { %>
<img src="<%= targetData.image[i] %>" />
<% } %>
I also tried
<% for(int i=0; i<6; i++) { %>
<img src="<%= targetData.image.concat('i') %>" />
<% } %>
Nothing seems to work. Kindly help me with a solution.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @revathi05,
Try this inside the loop:
<img src="<%= eval('targetData.image' + i) %>" />
Let me know if it worked.
Hi @revathi05,
Try this inside the loop:
<img src="<%= eval('targetData.image' + i) %>" />
Let me know if it worked.
Hi @revathi05,
Was @isahore's solution helpful to resolve your query? In case it was helpful, then kindly choose it as the 'Correct Reply'. If not and you still need more help, then do let us know.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies