I am very new to the JavaScript coding. In my JSP I am getting data from linked list and looping through the list to pass the value to a JavaScript function. Then I have a JavaScript function that retrieves the values and assigns it to the hidden fields. Now the problem is regardless of iteration my function always displays the last value in the array (Example if I have 2 rows in my array as for i =0 id =4, grp = HOCKEY sname= John and for i=1 id = 7 grp = SOCKER sname = Phil)
when I get back the value in my function it displays
ID =7 GRP = S NAME = P
instead of this
ID =4 GRP = HOCKEY NAME = John
ID =7 GRP = SOCKER NAME = Phil
I am not sure why it is doing that. Gurus please help me. Or is there any othere way to achieve this. Thanks in advance.
Here is the code snippet. Please ignore jsp code
if(iterator.hasNext()) { String name = (String)iterator.next(); LinkedList result = (LinkedList)hMap.get(name); %>
I changed my javascript function call to this <a href="JavaScript:selectProgram(id[<%= i%>] = new Array('<%= childBean.getStudentId()%>'), grp[<%= i%>] = new Array('<%= childBean.getGroupId()%>'), sname[<%= i%>]= new Array('<%= childBean.getName()%> ' );"
Now it dispalys complete value like this ID =7 GRP = SOCKER NAME = Phil But still it displays the last element in an array.
Bear Bibeault
Author and opinionated walrus
Marshal