*
The moose likes HTML, CSS and JavaScript and the fly likes Can I Iterate through an Arraylist inside a javascript funtion? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Can I Iterate through an Arraylist inside a javascript funtion?" Watch "Can I Iterate through an Arraylist inside a javascript funtion?" New topic
Author

Can I Iterate through an Arraylist inside a javascript funtion?

Anoobkumar Padmanabhan
Ranch Hand

Joined: Aug 08, 2007
Posts: 103
Hi ranchers

In my application, i want to iterate through an Arraylist at onClick event of a button. Can i do the iteration inside a javascript function??


Thanks<br /> <br />Anoobkumar<br />SCJP 1.5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

There is no ArrayList in JavaScript. That's a Java construct.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Anoobkumar Padmanabhan
Ranch Hand

Joined: Aug 08, 2007
Posts: 103
Bear,

i want to iterate through an arraylist. Can i call a java method from the javascript, so that the iteration can done inside the method?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Java runs on the server, JavaScript runs on the client.

If you want to call some Java code, you would have to post back a page through a normal postback OR an Ajax call. OR you have to turn the ArrayList on the server into some sort of JavaScript code when the page first is rendered.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Please read through this article to understand why this can never be.
 
 
subject: Can I Iterate through an Arraylist inside a javascript funtion?
 
Similar Threads
How to pass xmlresponse to another jsp in struts1.3?
struts 1.3 and iterate simultaneously over two or more ArrayList
Struts Form Type question
Handling dynamic select boxes on client side
Iterate through fields in an Inner Class