File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes javascript passing value to JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "javascript passing value to JSP" Watch "javascript passing value to JSP" New topic

javascript passing value to JSP

arpit singla
Ranch Hand

Joined: Jun 18, 2001
Posts: 66
I have a jsp displaying elements in a table. This jsp has embedded JavaScript. I want to pass value of variable from Javascript to JSP to display the updated value. Is it possible ? if this is not possible then how can i do it.
the way i am trying to do unsuccessfully :
// code for getting attributes

<script language="JavaScript">
function myfunction()
var myvar;
// code
document.chkout.textbox.value = myvar;


<form name="chkout">
// calling myfunction .....
<td align="left"><b> Grand Total </b></td>
<td align="center"> <input type="text" name="textbox" value=??> </td>
thanks a lot for your suggestions and help..
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
This is a little confusing. JSP's are run on the Server and the resulting page (usually rendered in html) is sent to the client. JavaScript runs client side after it is rendered as html. What is your requirements? Do you want the Page to display a running total of the values that are entered in the a text form element?
If this is the case, here is one quick solution:

[This message has been edited by Carl Trusiak (edited August 08, 2001).]

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Sandeep Jain
Ranch Hand

Joined: Oct 25, 2000
Posts: 124
If I have undestood what your requirement is , then I think it is possible. You can call the jsp from the javascript . and pass the value to the jsp.

Try and Try Till u succeed
Sandeep Jain

Try and Try Till u succeed<br /> <br />Sandeep Jain
I agree. Here's the link:
subject: javascript passing value to JSP
jQuery in Action, 3rd edition