如何从JavaScript访问arraylist,字符串数组或列表? [英] how to access arraylist, string array, or list from javascript?

查看:89
本文介绍了如何从JavaScript访问arraylist,字符串数组或列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过单击服务器端上的按钮来调用一个javascript函数,并将arraylist,字符串数组或list作为参数传递给函数.然后,我需要遍历这些集合的所有元素,并对数据执行一些操作.您能告诉我访问这些元素的JavaScript代码吗?

考虑一下我在Javascript中具有的以下结构:

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:

function ABC(_Arraylist/List/String Array){

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

}





Thanks.

推荐答案

用于生成和访问集合的示例代码为:

Sample code to generate and access a collection is:

<script type="text/javascript">
    function generate(){
        var arr = new Array();
        <c:forEach items="


{文章}" var =" a" varStatus =" >
{articles}" var="a" varStatus="status">


('#listitems').append( " li
('#listitems').append( "<li>"+


这篇关于如何从JavaScript访问arraylist,字符串数组或列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆