Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Javascript variable in vector

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

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

var test = 1 ;

<% 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.



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 ); %>

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

<% 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.