• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javascript passing value to JSP

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :
myjsp:
<html>
<head>
// code for getting attributes

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

}
</script>
</head>
<body>

<form name="chkout">
<table>
// calling myfunction .....
<tr>
<td align="left"><b> Grand Total </b></td>
<td align="center"> <input type="text" name="textbox" value=??> </td>
</tr>
</table>
</form>
</body>
</html>
thanks a lot for your suggestions and help..
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
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.
document.form.action="http://172.16.80.92:8000/servlets/first.jsp?name=javascriptVar1&age=javascriptVar2"
document.form.method=post;
document.form.submit();

------------------
Try and Try Till u succeed
Sandeep Jain
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic