Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parameter from jsp to javascript function?

 
deep venu
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i pass a vector(or array) from jsp to a javascript function?
 
Julio Lopez
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Julio!
thanx alot..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic