This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
How to call JavaScript Function from jsp
jsp and javascript
returning value from jQuery
Javascript function call
Need help on calling javascript without any handler from JSP..