This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Variable  RSS feed

 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get the value of an attribute and get it from javascript.I tried with the following code but it didn't work,any ideas?

<%
String currentCorpusId = request.getSession().getAttribute("currentCorpusId");

<%
<script>
var currentCorpusId=<%= currentCorpusId %>;
</script>

thanks
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks ok to me.
Assuming currentCorpusId is a number of some sore it should generate code like



perfectly valid javascript in my book.

What doesn't work about it?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the <% aren't matched?

-Cameron McKenzie
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Cameron pointed out, your example will not even translate.

If that's the way your code is, that's the problem. If not, please take better care when posting so as not to waste the time of people trying to help you.

but it didn't work


This is not useful information. How did it not work?
[ November 08, 2006: Message edited by: Bear Bibeault ]
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,yes there was an error with the <% ,I corrected it but still and I have an error...
The error I get when loading the page in javascritp is "sintax error"...

<%
String currentCorpusId = request.getSession().getAttribute("currentCorpusId");
%>
<script type="text/javascript">
var currentCorpusId=<%= currentCorpusId %>;
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I corrected the error myself

thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!