Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Looping through target variable

Avatar

Level 1

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.

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @revathi05,

Try this inside the loop:

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

 

Let me know if it worked.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @revathi05,

Try this inside the loop:

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

 

Let me know if it worked.

Avatar

Administrator

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.



Sukrity Wadhwa