hello all, my code is like this:
<%
ArrayList<Item> itemList = new ArrayList<Item>();
itemList = projr.getObjects(projectID);
if (itemList.size() != 0) {
%>
<script type="text/javascript">
window.onload = function() {
for(var i = 0;i < <%=itemList.size()%>;i++){
var azimuth=0;
azimuth = <%=itemList.get(i).getAzimuth()%>;
</script>
<%
}
%>
basically as you can see, due to certain reasons, i need to do the for loop within javascript. However, I cannot use the variable 'i' declared in javascript within the jsp<%=%> tag. Hence, I was wondering if there could be any work arounds.
I've tried to store 'i' as a cookie and try to retrieve it in the jsp by doing smth like:
azimuth = <%=itemList.get(Integer.parseInt((request.getCookies())[0].getValue())).getAzimuth()%>;
However, sadly this doesn't work. Also, I've thought of using hidden input fields to store 'i' but I don't think it would work as even if a did a request.getParameter(input name), i would not get anything as I have not submitted anything. Am I correct to say that?
I would appreciate if any of you kind souls could help me out here =]