A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
JSP
Author
Re:Assign jsp variable into javascript variable
Muthiah Raja
Greenhorn
Joined: Feb 06, 2005
Posts: 9
posted
Nov 23, 2005 22:50:00
0
I am trying to assign
JSP
String
variable to Javascript variable.
For that i use the follwing code
<% String str="Raja"; %>
var s=<%=str%>;
alert(s);
But this code is not worked.
Instead of writting var s=<%=str%>;
I try var s='<%=str%>';
I try var s="<%=str%>";
this code also not worked.
Kindly help me.
pankaj patil
Ranch Hand
Joined: Dec 19, 2004
Posts: 98
posted
Nov 24, 2005 00:41:00
0
Change the code from
<% String str="Raja"; %>
var s=<%=str%>;
alert(s);
to
<% String str="Raja"; %>
var s="<%=str%>";
alert(s);
This will work
Regards,
Pankaj Patil
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
I like...
posted
Nov 24, 2005 02:28:00
0
Muthina,
Please don't spread one conversation over more than one thread.
This is a continuation of:
http://www.coderanch.com/t/288527/JSP/java/Assign-Jsp-variable-Javascript-variable
I will respond there.
Java API
J2EE API
Servlet Spec
JSP Spec
How to ask a question...
Simple Servlet Examples
jsonf
I agree. Here's the link:
http://aspose.com/file-tools
subject: Re:Assign jsp variable into javascript variable
Similar Threads
Assign Jsp variable to Javascript variable
get string values from Request and Session
tree like select list (html)
how can i put java script value into jsp variable?
compare jsp variable and javascript variable
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter