Looping through target variable | Community
Skip to main content
New Participant
May 26, 2023 8:37 AM UTC
Solved

Looping through target variable

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.

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
isahore
isahoreAccepted solution
New Participant
May 26, 2023 11:30 AM UTC

Hi @revathi05,

Try this inside the loop:

<img src="<%= eval('targetData.image' + i) %>" />

 

Let me know if it worked.

2 replies

Sukrity_Wadhwa
Employee
Jun 7, 2023 9:42 AM UTC

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.

Translate
Sukrity Wadhwa
isahore
isahoreAccepted solution
New Participant
May 26, 2023 11:30 AM UTC

Hi @revathi05,

Try this inside the loop:

<img src="<%= eval('targetData.image' + i) %>" />

 

Let me know if it worked.

Translate