Window. Location for button click w/ session vars
Here's the code so far, and it says strWPID is not defined.
This is an .asp page:
Code:
if (!navigator.javaEnabled())
{
window.location = "javanotenabled.asp";
} else {
<%
strWPID = session("sessionWPID")
strDB = session("sessionDB")
strPC = session("sessionPC")
strCA = session("sessionCA")
strWPN = session("sessionWPN")
%>
window.location = "MainMenu.asp?WPID="+strWPID+"&DB="+strDB+"&PC="+ strPC +"&CA=" + strCA +"&WPN="+ strWPN;
//vername="+vername+"&verno="+verno;
}
...but it's not working..any suggestions?
It says javascript error of:
strWPN is not defined
[674 byte] By [
bubberz] at [2007-11-11 7:58:21]

# 1 Re: Window. Location for button click w/ session vars
You're confusing server-side vs. client-side variables. They exist in entirely different places.
Here's what your code should look like:
window.location = "MainMenu.asp?WPID=<%=strWPID%>&DB=<%=strDB%>&PC<%=strPC%>&CA<%=strCA%>&WPN=<%=strWPN%>";
# 3 Re: Window. Location for button click w/ session vars
...oops! I forgot something:
You should also use the URLEncode() method when building a URL. This will automatically replace blank spaces with %20 and all the other weird stuff that needs to be changed in a URL. Your window.location stmt would look like this:
window.location = "MainMenu.asp?WPID=<%=URLEncode(strWPID)%>&DB=<%=URLEncode(strDB)%>&PC<%=URLEncode(strPC)%>&CA<%=URLEncode(strCA)%>&WPN=<%=URLEncode(strWPN)%>";
Likewise, when accessing strings that have been passed in through a URL, you should decode them using URLDecode().