Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes parameter from jsp to javascript function? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "parameter from jsp to javascript function?" Watch "parameter from jsp to javascript function?" New topic
Author

parameter from jsp to javascript function?

deep venu
Ranch Hand

Joined: Jun 09, 2001
Posts: 56
how can i pass a vector(or array) from jsp to a javascript function?
Julio Lopez
Greenhorn

Joined: Nov 14, 2000
Posts: 28
Just write the javascript array out using a loop. Assuming vector is referenced by v,
<%
int count = 0;
%>
var theArray = new Array(<%= v.size() %> )
<%
for (Enumeration e = v.elements() ; e.hasMoreElements() {
%>
theArray[<%= count %>] = "<%= e.nextElement() %>"
<%
count++;
}
%>
This should work.
Julio Lopez
M-Group Systems
deep venu
Ranch Hand

Joined: Jun 09, 2001
Posts: 56
hi Julio!
thanx alot..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: parameter from jsp to javascript function?
 
Similar Threads
jsp and javascript
How to call JavaScript Function from jsp
returning value from jQuery
Javascript function call
Need help on calling javascript without any handler from JSP..