Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic