I have a question about transfer information between JSP and Javascript. I have a
Vector variable,it has several values,such as "Peter","John","Kate". I show it in the
table and show one each time.I provide a link,when click this link,show next value.For
example: first time show "Peter",when I click this link,it shows "John" and so on.But
I encounter a question.I don't know how to transfer value back to JSP. I write code to
realize it,but when I click link,I found the value don't changed! Why?
My code is follows:
/*test.jsp*/
<%@ page import="java.util.Vector" %>
<%!
int index=0;
%>
<%
Vector v=new Vector();
String username;
String name="Peter";
v.add(name);
name="John";
v.add(name);
name="Kate";
v.add(name);
username=(String)v.get(index);
%>
<script language="JavaScript">
<!--
function PageNext()
{
index++;
document.thisform.submit();
}
-->
</script>
<html>
<%
username=(String)v.get(index);
%>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<div align="center" >
<form name="thisform" method="post" action="test.jsp">
<table width="100%" border="1" class="font10" cellspacing="1" cellpadding="1"
bgcolor="#FFFFFF" bordercolor="#999999">
<TD bgcolor="#DFDFDF" width=100><B>Name</B></TD>
<TD width=100><B><%=username%></B></TD>
</table>
<table>
<TR valign=baseline align=center>
<TD width=150><A Href="Javascript:PageNext();">Next Page</A></TD
</TR>
</table>
</form>
</div>
</body>
</html>
How to realize it?
Any idea will be appreciated!
Best Regards,
Edward
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com