Hi Buddies,

My views regarding this topic are somewhat different.
I think it is not good to reload the page every time you want to access the
next element in the array.

The reason of "index" not getting auto-incremented is that array is being
constructed on Server side. So every time page is getting re-loaded using
PageNext() function.

So a better solution will be to store the array on the page or in Session
and access that array using Javascript without re-loading the page.

Hope that helps.

Regards,
Sandeep


-----Original Message-----
From: sathish [mailto:[EMAIL PROTECTED]
Sent: Monday, March 24, 2003 10:48 AM
Subject: Re: How to transfer information between JSP and Javascript?


> <!--
> function PageNext()
> {
>    index++;
>    document.thisform.submit();
> }
> -->
the function u have return in the javascript PageNext() is incrementing
java variable so u need to add the tag like <%index++%>; again what will
happen is every time it gets incremented while page gets load and u will
see the output as peter and when click next it'll show kate.

i u like to work it out properly ,don't use default submit instead use
some document.location property and send the index value in the url.


-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED] On Behalf Of jay halvorson
Sent: Sunday, March 23, 2003 9:47 PM
To: [EMAIL PROTECTED]
Subject: Re: How to transfer information between JSP and Javascript?

Not really a javascript guy, but how about using
document.thisform.index.value++ instead of index++ .

I believe index++ would be referencing a javascript
variable local to the PageNext function.



----- Original Message -----
From: "Edward King" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, March 22, 2003 10:38 PM
Subject: How to transfer information between JSP and Javascript?


>   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

========================================================================
===
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

===========================================================================
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

Reply via email to