Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Javascript variable in vector

  Asked By: Loretta    Date: May 09    Category: Java    Views: 1221
  

I have one Javascript varialble. I want to add that variable in
Vector.


<script>
var test = 1 ;
</script>

<% Vector myVector = new Vector();
myVector.addElements(//here I want to add javascript variable ) ; %>


I want to insert test variable. Can anyone please let
me know the syntax.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Vivian Ruiz     Answered On: May 09

Anything within <% ... %> tags are parsed and
executed on the server while javascript  runs on the
client machine. Now you could go the other way around
like this.

<% Integer testVar = new Integer( 1 ); %>

<script>
var test  = <%= testVar.intValue() %>;
</script>

<% Vector myVector = new Vector();
myVector.addElements( testVar ) ; %>

 
Didn't find what you were looking for? Find more on Javascript variable in vector Or get search suggestion and latest updates.




Tagged: