Get the JavaScript variable into JSP
Do anybody know how to get the variable from JavaScript into JSP's variable?
for example:
<script language="JavaScript">
<!-- Hide
for(i=0;i<10;i++)
{
temp = <%=name.elementAt(i)%> //this JSP's "i" should be equal to the JavaScript's "i"
}
[323 byte] By [
tsangboy] at [2007-9-26 1:28:29]

<script language="JavaScript">
<!-- Hide
for(i=0;i<10;i++)
{
temp = <%=name.elementAt(i)%> //this JSP's "i" should be equal to the JavaScript's "
Hope "name" is a vector right?
what you do is
define an array variable and assign with this vector values..
Even you can use a String (JavaScript variable )
Generate stings..like s1|s2|..etc
then use split method in String to get array.
sribk at 2007-6-29 1:14:21 >

No you can't include ..
eg..
say that you have a vector
<%
Vector vecNames = new Vector();
vecNames .addElements("rohit29");
vecNames .addElements("rohit30");
vecNames .addElements("rohit31");
vecNames .addElements("rohit32");
int i=0;
String str="";
while (i < vecNames.size()){
str +=vecNames.toString().trim()+"|";
}
%>
<script>
var strString=<%= str %>;
function functionTest(){
var strArray = strString.split("|");
for(i=0;i< strArray.length;i++)
{
alert(strArray);
}
</script>
Hope this is what you needed... ?
sribk at 2007-6-29 1:14:21 >
