Reputation: 4267
With JSTL I have to build an array (in string format) and then pass it to a Javascript function.
My gol is to have a string like this: "abc","ghjh","fsd"
I started doing something like this:
<c:forEach items="${items}" var="item">
<c:set var="array">${array}"${item.value}"</c:set>
</c:forEach>
<script>
var sliderLinks = [<c:out value="${array}"/>];
</script>
But when I see the source code of the instead of " I have "
I tried this solution but I keep on getting the same problem.
Thank you in advance
Upvotes: 0
Views: 754
Reputation: 1163
You can push the items into the array one by one:
<script>
var sliderLinks = new Array();
<c:forEach items="${items}" var="item">
sliderLinks.push(${item.value});
</c:forEach>
</script>
Upvotes: 2