knaren_1975
asked on
How to assign JSP Variable to JavaScript
Hi
i have a function like below
function sortResults(sortOption) {
<% if(request.getAttribute("i d")!=null) {
String pId = (String)request.getAttribu te("id");
var proId= '<%=pId%>';
}%>
}
i am not able to assign the pid value to proId it is showing null..where as i am getting the id value
please let me whethe i am properly assign this jsp value in java script variable
i have a function like below
function sortResults(sortOption) {
<% if(request.getAttribute("i
String pId = (String)request.getAttribu
var proId= '<%=pId%>';
}%>
}
i am not able to assign the pid value to proId it is showing null..where as i am getting the id value
please let me whethe i am properly assign this jsp value in java script variable
Or this, depending on which part is javascript and which is jsp
function sortResults(sortOption) {
if(request.getAttribute("id")!=null){
<%
String pId = (String)request.getAttribute("id");
%>
var proId= '<%=pId%>';
}
}
function sortResults(sortOption) {
<% if(request.getAttribute("id")!=null){
String pId = (String)request.getAttribute("id");
%>
var proId= '<%=pId%>';
<%
}%>
}
ASKER
it's not working...
i am getting the request.getAttribute("id") value but i am not able to assign this value into javascript varible
i but some debug statement then i can see the value coming into this.
when i add the code var proId= '<%=pId%>'; my jsp page itself is not opening just saying null in this Jsp
Regards
Naren
i am getting the request.getAttribute("id")
i but some debug statement then i can see the value coming into this.
when i add the code var proId= '<%=pId%>'; my jsp page itself is not opening just saying null in this Jsp
Regards
Naren
did u try
function sortResults(sortOption) {
<% if(request.getAttribute("id")!=null){
String pId = (String)request.getAttribute("id");
%>
var proId= '<%=pId%>';
<%
}%>
}
function sortResults(sortOption) {
var proId= '<%= (request.getAttribute("id" )!=null)?( String)req uest.getAt tribute("i d"):"" %>';
}
var proId= '<%= (request.getAttribute("id"
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THx
Did you try mine?
Open in new window