Click here to Skip to main content
16,021,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to call one javascript function from my button click on server side and pass the arraylist, string array or list as a parameter to the function. I would then need to iterate through all the elements of these collection and perform some action on the data. Can you tell me the javascript code to access these elements ?

Consider the following structure that I have in the Javascript:

JavaScript
function ABC(_Arraylist/List/String Array){

//I would like to perform some action on the collections data here. 

}


Thanks.
Posted
Updated 11-Feb-12 22:09pm
v2

Sample code to generate and access a collection is:

XML
<script type="text/javascript">
    function generate(){
        var arr = new Array();
        <c:forEach items="${articles}" var="a" varStatus="status">
            $('#listitems').append(
                "<li>"+${a.title}+"</li>"
            );
            arr[${status.index}] ="${a.slideShow.images}";
        </c:forEach>
    }
    function generate(){
        var arr = new Array();
        <c:forEach items="${articles}" var="a" varStatus="status">
            alert(arr[${status.index}]);            
        </c:forEach>
</script>
 
Share this answer
 
Used the string instead of passing arraylist to the javascript and then created the arrays from the string.This solved my problem
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900