Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Please help me.

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, all.
I want to use JavaScript's variable in JSP block. I know JavaScript is Client-Side script and JSP is Server-Side script, so, following code is impossible, but I hope it's another way to achieve my aim. Please help me.
SCRIPT language=JavaScript>
function loadSubMenu(Value){
<% Vector term1 = teacher.getTerm(Value); //I want to use JavaScript's variable "Value"
%>
}
</SCRIPT>
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no way......
it's impossible.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the flow of things:
JSP Run -> client receives page -> JavaScript Runs
JavaScript can never talk directly to JSP, since in a Page's life, JSP is "done" by the time JavaScript starts executing.
What you want to do may be possible, but not the way you are thinking about doing it. You could load the page again (controlled by JavaScript) passing the value of the JavaScript variable as a parameter on the request. For example "mypage.jsp?field=value".
We might be able to provide more help if we knew more (from and end user perspective) what you were trying to accomplish.
-Pete
[ March 27, 2003: Message edited by: Peter Daly ]
 
Michael Zhang
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this,
<form name="form1" action="">
<input type="hidden" name="a" value="">
</input>
<script language="javascript">
//set value of "a"
//set action of "form1"
form1.submit()
</script>
 
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic