I have a requirement to call a javascript function inside c:foreach. Please give me a idea how to call. I will loop through usertimetrackersummary inside foreach and need to call javascript function for every looping.
Now javascript function is called every looping but i'm getting empty value if i try to print 'totalOffHomeHrs' in table data. td
<c:forEach items="${userTimeTrackerSummary}" var="userTimeTracker">
<script type="text/javascript">
var totalOffHomeHrs= addTimes('${userTimeTracker.totalWorkhours}','${userTimeTracker.totalWorkHomehours}');
</script>
<tr style="font-size:11px;">
<td ><c:out value="${userTimeTracker.employeeID}" /></td>
<td>${totalOffHomeHrs}</td>
</tr>
</c:forEach>
javascript function:
function addTimes(t0, t1) {
return timeFromMins(timeToMins(t0) + timeToMins(t1));
}
Finally i m able to achieve the requirement in below code. Please suggest if there is an alternative elegant way.